Learn Java FizzBuzz Project

Hi please can someone help me with the fizz buzz project on learn java.

Fizzbuzz Learn Java

This is the code I used:

public class FizzBuzz {

  public static void main(String[] args) {

    for(int = 1; i <= 100; i++) {

      if(i%5 == 0 && i%3 ==0) {
        System.out.println("fizz buzz");
      } else if (i%3 == 0) {
        System.out.println("fizz");
      } else if (i%5 == 0) {
        System.out.println("buzz");
      } else { 
        System.out.println(i);
      }
    }   
  }
}

There isn’t an error, but the output format is not correct:
1
2
fizz
3

No that does not output anything, it does not compile.

1 Like

Nevermind…I fixed it - needed int i=1

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.