Getting While error at compile time

Hi! Can you tell me what I’m doing wrong here? The compiler is asking for a ‘;’ at the end of the ‘While’ statement. But no ‘;’ belongs at the end of the ‘While’ statement–so what have I got wrong here?

Thanks much!

–Ilene

Error: FizzBuzz.java:7 :error: ‘;’ expected
While (j<= 100) {
^

FizzBuzz
here’s the link to the exercise^

and here’s the entire code:

public class FizzBuzz {

public static void main(String args){
System.out.println(“Starting”);
int j = 0;
String myOutput = “”;
While (j <= 100) {
j = j++;
if ((j % 3)= 0 && (J % 5 ) = 0) {
myOutput = “FizzBuzz”;
} else if ((j % 3) = 0) {
myOutput = “Fizz”;
} else if (j % 5 = 0) {
myOutput = “Buzz”;
} else {
myOutput = j.toString();
}
System.out.println(myOutput);
}
} //while
} // main

In your if / else if / else statement,

shouldn’t you be comparing, rather than assigning values?

The assignment operator =/= the comparison operator :slight_smile:

1 Like

Yes, I didn’t get to that point because it won’t compile.

Thanks for the tip!

2 Likes

I fixed the assignment vs comparison symbols. Compiled. Still got the same error with the ‘while’ statement.

You wrote While, should be while.

Also, careful with this line

if ((j % 3) == 0 && (J % 5 ) == 0) {

Notice the second j

1 Like