1234567891011121314151617181920212223242526272829303132333435363738
  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. // instance variables - replace the example below with your own
  10. private int x;
  11. /**
  12. * Constructor for objects of class FizzBuzz
  13. */
  14. public FizzBuzz(){
  15. }
  16. public String result(int input) {
  17. if (input % 3 == 0 && input % 5 == 0) {
  18. return "FizzBuzz";
  19. }
  20. else if(input % 3 == 0) {
  21. return "Fizz";
  22. }
  23. else if (input % 5 == 0) {
  24. return "Buzz";
  25. }
  26. else {
  27. return String.valueOf(input);
  28. }
  29. }
  30. }