i want to make my code better
question *****
* *
* *
* *
*****
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
//code for *****
int row = 1;
int star=1;
while (star<=n) {
System.out.print("");
star++;
}
System.out.println();
row++;
//code for * *
while (row<=n-1) {
int nst = 1;
while (nst<=n) {
if (nst == 1) {
System.out.print("");
}
else if (nst>1 && nst<n) {
System.out.print(" ");
}
else if (nst==n) {
System.out.print("*");
}
nst++;
}
System.out.println();
row++;
//code for *****
while (row==n) {
int mass=1;
while (mass<=n) {
System.out.print("*");
mass++;
}
row++;
}
}
}
}