Trying to print pattern like half sphere below i have added actual output and expected output along with my code can anyone help how to do it. Thanks in advance
My code
public class PatternHalfSphere {
public static void main(String[] args) {
int i,j;
for(i = 1;i<=4;i++){
System.out.println();
for(int k=3;k>=i;k--){
System.out.print(" "+"*"+" ");
}
for(j=1;j<=i;j++){
System.out.print(" ");
}
}
for(int k=0;k<=3;k++) {
for(int l = 0; l<k;l++)
{
System.out.print(" "+"*"+" ");
}
System.out.println();
}
}
}
Actual output
* * *
* *
*
*
* *
* * *
Expected output
* * *
* *
*
* *
* * *