12345678910111213141516171819202122232425 |
-
- /**
- * Write a description of class FizzBuzz here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class FizzBuzz
- {
- public FizzBuzz() {
- }
-
- public String fizzBuzz(int n) {
- String output = "" + n;
- if (n % 3 == 0 && n % 5 == 0) {
- output = "FizzBuzz";
- } else if (n % 3 == 0) {
- output = "Fizz";
- } else if (n % 5 == 0) {
- output = "Buzz";
- }
- return output;
- }
- }
|