FizzBuzz.java 488B

12345678910111213141516171819202122232425
  1. /**
  2. * Write a description of class FizzBuzz here.
  3. *
  4. * @author (your name)
  5. * @version (a version number or a date)
  6. */
  7. public class FizzBuzz
  8. {
  9. public FizzBuzz() {
  10. }
  11. public String fizzBuzz(int n) {
  12. String output = "" + n;
  13. if (n % 3 == 0 && n % 5 == 0) {
  14. output = "FizzBuzz";
  15. } else if (n % 3 == 0) {
  16. output = "Fizz";
  17. } else if (n % 5 == 0) {
  18. output = "Buzz";
  19. }
  20. return output;
  21. }
  22. }