Created
December 21, 2021 13:57
-
-
Save sklarow/f28a4254ffde944d9b6145480d08ec8f to your computer and use it in GitHub Desktop.
FizzBuzz Exercise in Java!
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
public class FizzBuzz { | |
public static void main(String[] args) { | |
for (int number=1; number <= 100; number++){ | |
String result = ""; | |
if (number % 3 == 0) | |
result = "Fizz"; | |
if (number % 5 == 0) | |
result += "Buzz"; | |
if (result.equals("")) | |
System.out.println(number); | |
else | |
System.out.println(result); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment