I'm attempting a shape-making Java project, and I keep getting a syntax error on my while loop that I can't figure out - any suggestions?
Here's my code thus far:
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
System.out.println("Hello! I am a program that draws shapes, but YOU must tell me how big you wish me to make them!");
System.out.println("Enter shape size: ");
final int MAX_ROWS = scan.nextInt();
// DIAMOND
int spaces = 0, stars, row;
for (row = 1; row <= (MAX_ROWS + 1) / 2; row++) {
for (spaces = 0; spaces < MAX_ROWS - row; spaces++) {
System.out.print(" ");
}
for (stars = 0; stars < row; stars++) {
System.out.print("* ");
}
System.out.println("");
}
for (row = ((MAX_ROWS + 1) / 2); row < MAX_ROWS; row++) {
for (spaces = 1; spaces < row; spaces++) {
System.out.print(" ");
}
for (stars = 0; stars < MAX_ROWS - row; stars++) {
System.out.print(" *");
}
System.out.println("");
}
System.out.println("Diamond, size " + MAX_ROWS + ".");
}
// HOLLOW SQUARE
int loopVariable = 0;
private static final int MAX_ROWS
while(loopVariable < MAX_ROWS) { <--- THIS IS THE SYNTAX ERROR LINE
if(loopVariable == MAX_ROWS - 1 ||
loopVariable == 0) {
for(int x=0; x < MAX_ROWS; x++) {
System.out.print("* ");
}
} else {
for(int x=0; x < MAX_ROWS; x++ ) {
if(x == 0||x == MAX_ROWS-1) {
System.out.print("* ");
} else {
System.out.print(" ");
}
}
}
System.out.println();
System.out.println("Hollow Square, size " + MAX_ROWS + ".");
loopVariable++;
}
}
These are the errors it's giving me:
Multiple markers at this line - Syntax error on token "while", = expected - Syntax error, insert ";" to complete FieldDeclaration
Thanks in advance!
;after the line that is previous to your while loop.