Created
June 7, 2016 14:48
-
-
Save ArielSaldana/1fb62932c7d05314b81235d4205a1436 to your computer and use it in GitHub Desktop.
This file contains 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
package com.ariel.fizzbuzz; | |
/* | |
* Fizz Buzz is an interview question designed to help filter out the 99.5% of programming job candidates who can't | |
* program their way out of a wet paper bag. The text of the programming assignment is as follows : | |
* "Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number | |
* and for the multiples of five print "Buzz". For numbers which are multiples of both tree and five print "FizzBuzz". | |
*/ | |
public class Main { | |
public static void main(String[] args) { | |
// write your code here | |
boolean isFizzBuzz = false; | |
for (int i = 1; i <= 100; i++) { | |
if (i %3 == 0) { | |
System.out.print("Fizz"); | |
isFizzBuzz = true; | |
} | |
if (i % 5 == 0) { | |
System.out.print("Buzz"); | |
isFizzBuzz = true; | |
} | |
if(!isFizzBuzz) { | |
System.out.print(i); | |
} | |
System.out.println(); | |
isFizzBuzz = false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment