123456789101112131415161718192021222324
  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 String of(int x) {
  10. String fizz = "";
  11. if (x % 3 == 0 && x % 5 == 0) {
  12. fizz = "FizzBuzz";
  13. } else if (x % 3 == 0) {
  14. fizz = "Fizz";
  15. } else if (x % 5 == 0) {
  16. fizz = "Buzz";
  17. } else {
  18. fizz = "" + x;
  19. }
  20. return fizz;
  21. }
  22. }