not able to get desired output
program i wrote
package assignments;
import java.util.Scanner;
public class Question8 {
public static void main(String[] args) {
Scanner scan =new Scanner(System.in);
System.out.println("enter value of n");
int n=scan.nextInt();
int nst=1;
int nsp=n-2;
int row=1;
while(row<=n)
{
if(row==1||row==n)
{
for(int cst=1;cst<=nst;cst++)
{
System.out.print("*");
}
for(int csp=1;csp<=nsp;csp++)
{
System.out.print(" ");
}
for(int cst=1;cst<=nst;cst++)
{
System.out.print("*");
}
}
else if(n%2==0)
{
for(int i=1 ;i<n;)
{
System.out.print(" ");
System.out.print("*");
i=i+2;
}
}
else
{
for(int i=1 ;i<=nsp;)
{
if(i<nsp)
{
System.out.print(" ");
}
else
{
System.out.print("*");
}
i=i++;
}
}
System.out.println();
row++;
}
}
}