my code pass one test case that is other test casesā¦which my code does not passā¦also give me the right code
Scanner sc = new Scanner(System.in);
int n= sc.nextInt();
if(n>=5 && n<= 99 && n%2!=0)
{
int nsp = n-5;
for(int row =1 ; row<=n ;row++)
{
if(row>(n/2)+1 && row<n)
{
System.out.print(" ");
}
else
{
System.out.print("*");
}
// work for spaces
for(int csp =1;csp<=nsp;csp++)
{
if(row != (n/2)+1 && row!=n)
{
System.out.print(" ā);
}
else
{
System.out.print(ā*");
}
}
// work for stars
System.out.print("");
// work for soace sand stars
for(int csp=1;csp<=nsp;csp++)
{
if(row!=1 && row != (n/2)+1)
{
System.out.print(" ā);
}
else
{
System.out.print(ā");
}
}
// again work for starts and spaces
if(row>1 && row<=n/2)
{
System.out.print(" ā);
}
else
{
System.out.print(ā*");
}
System.out.println();
}
}