Hi all!
I am doing the following exercise: Learn Java | Codecademy | FizzBuzz
The output for code is ALMOST right. Fizz and Buzz seem to come out on the intended numbers. But BuzzFizz won’t output the multiples of 3 and 5.
Here’s what I have tried for that else if statement:
else if(i % 15 == 0) {
System.out.println("FizzBuzz")
// other version I have tried:
else if (i % 3 == 0 && i % 5 ==0) {
System.out.println("FizzBuzz");
Snippet of code
public class FizzBuzz {
public static void main(String[] args) {
for (int i = 1; i < 100; i++) {
if(i % 3 == 0) {
System.out.println("Buzz");
}
else if(i % 5 == 0) {
System.out.println("Fizz");
}
else if(i % 15 == 0) {
System.out.println("FizzBuzz");
}
else {
System.out.println(i);
}
}
}
}