fizzBuzz.java 808B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. /**
  10. * Constructor for objects of class fizzBuzz
  11. */
  12. public fizzBuzz()
  13. {
  14. }
  15. /**
  16. * An example of a method - replace this comment with your own
  17. *
  18. * @param y a sample parameter for a method
  19. * @return the sum of x and y
  20. */
  21. public String fizzBuzz(int y)
  22. {
  23. String result ="";
  24. if (y % 5 == 0 && y % 3 == 0){
  25. result = "fizzBuzz";
  26. }else if (y % 3 == 0){
  27. result = "fizz";
  28. }else if (y % 5 == 0){
  29. result = "buzz";
  30. }else{
  31. result = Integer.toString(y);
  32. }
  33. return result;
  34. }
  35. }