FizzBuzz1.java 547B

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