Created
January 20, 2011 15:19
-
-
Save jaredcacurak/788040 to your computer and use it in GitHub Desktop.
An implementation of the FizzBuzz.
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
| package com.rocketpush.puzzle; | |
| public class FizzBuzz { | |
| public static String fizzBuzz(boolean isFizzy, boolean isBuzzy, int i) { | |
| String value = String.valueOf(i); | |
| if (isFizzy && isBuzzy) { | |
| value = "FizzBuzz"; | |
| } else if (isFizzy) { | |
| value = "Fizz"; | |
| } else if (isBuzzy) { | |
| value = "Buzz"; | |
| } | |
| return value; | |
| } | |
| public static void main(String... args) { | |
| for (int i = 1; i <= 100; i += 1) { | |
| boolean isFizzy = i % 3 == 0; | |
| boolean isBuzzy = i % 5 == 0; | |
| String result = fizzBuzz(isFizzy, isBuzzy, i); | |
| System.out.println(result); | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Watch me code at Interview Zen http://www.interviewzen.com/interview/bStyy via @interviewzen