Created
May 12, 2015 15:52
-
-
Save MrBean83/18527e6bdddc2d823ac2 to your computer and use it in GitHub Desktop.
Simple "Fizz Buzz" Program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FizzBuzz { | |
public static void main(String args[]) { | |
// Declare local variables | |
int num; | |
// Using a FOR loop for this program. | |
for (num = 1; num < 73; num++) { | |
if (num % 35 == 0) | |
System.out.println("FizzBuzz"); | |
else if (num % 7 == 0) | |
System.out.println("Buzz"); | |
else if (num % 5 == 0) | |
System.out.println("Fizz"); | |
else | |
System.out.println(num); | |
} // end for | |
} // end main | |
} // end class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment