code is:
import java.util.*;
public class Main {
public static void main(string args[]) {
public static void main(String[] args) {
Scanner scn=new Scanner(System.in);
int n= scn.nextInt();
int row=1;
while(row<=n)
{
if(row<=n/2)
{
System.out.print("*");
for(int csp=1;csp<=n/2-1;csp++)
{
System.out.print(" ");
}
System.out.print("*");
if(row==1) {
for(int cst=1;cst<=n/2;cst++)
{
System.out.print("*");
}
}
}
else if(row==n/2+1)
{
for(int cst=1;cst<=n;cst++)
{
System.out.print("*");
}
}
else {
if(row==n)
{
for(int csp=1;csp<=n/2;csp++)
{
System.out.print("*");
}
}
else
{
for(int csp=1;csp<=n/2;csp++)
{
System.out.print(" ");
}
}
System.out.print("*");
for(int csp=1;csp<=(n/2)-1;csp++)
{
System.out.println(" ");
}
System.out.print("*");
}
row++;
System.out.println();
}
}
}
output is not proper