FizzBuzzConverter.java 559B

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * Write a description of class FizzBuzzConverter here.
  3. *
  4. * @author (your name)
  5. * @version (a version number or a date)
  6. */
  7. public class FizzBuzzConverter
  8. {
  9. // public fizzBuzz(){}
  10. public String fizzBuzz(int y){
  11. String result ="";
  12. if(y %5 == 0 && y %3 ==0){
  13. result = "Fizz Buzz";
  14. }
  15. else if(y %3 == 0){
  16. result = "Fizz";
  17. }
  18. else if(y %5 == 0){
  19. return "Buzz";
  20. }else{
  21. result =Integer.toString(y);
  22. }
  23. return result;
  24. }
  25. }