FizzBuzz.java 452B

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