FizzBuzz.java 482B

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