This is my code for Ganeshaβs Pattern, upon submitting, it shows all three of my test cases has failed but this code works fine.
import java.util.;
public class Main {
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
for(int i=1; i<=n; i++){
if(i==1){
for(int j=1; j<=n; j++){
if(j>=2 && j<(n/2)+1){
System.out.print(" β);
} else {
System.out.print(β β);
}
}
} else if(i==(n/2)+1){
for(int j=1; j<=n; j++){
System.out.print(β* β);
}
} else if(i==n) {
for(int j=1; j<=n; j++){
if(j>(n/2)+1 && j<n){
System.out.print(β β);
} else {
System.out.print(β* β);
}
}
} else if(i<(n/2)+1){
for(int j=1; j<=(n/2)+1; j++){
if(j==1 || j==(n/2)+1){
System.out.print(β* β);
} else {
System.out.print(β β);
}
}
} else {
for(int j=1; j<(n/2)+1; j++){
System.out.print(β β);
}
for(int j=1; j<=(n/2)+1; j++){
if(j==1 || j==(n/2)+1){
System.out.print(β* β);
} else {
System.out.print(β ");
}
}
}
System.out.println();
}
}
}