Help with my FizzBuzz problem please

I am working on the FIzzBuzz activity and I cannot figure out how to get it to not print the numbers that satisfy my if else statements like 3,5,6,9,10,15 etc. Help understanding would be greatly appreciated.
Here is my code

1 Like

What keyword/concept have we learned which should occur when all other conditions are false? We if, else if, and what more?

1 Like

all I can remember is If, else if, else…

Would else be a good thing to use here?

Thanks… it is now fixed… I am trying to make sense of it in my head of how making it print my var i using else removes the extra printed numbers but I am going to go play with it some more to try to understand. I appreciate it.

} else{

System.out.println(i); }

when you don’t use else, the line which prints the number is always reached

using else will only print the number when all if and else if conditions are false

1 Like