12345678910111213141516171819202122232425262728293031323334353637 |
-
- /**
- * Write a description of class FizzBuzz here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class FizzBuzz
- {
- // instance variables - replace the example below with your own
- private int x;
-
- /**
- * Constructor for objects of class FizzBuzz
- */
- public FizzBuzz()
- {
- // initialise instance variables
-
- }
-
- public String fizzbuzz(int y)
- {
- String result = "";
- if(y%3 == 0 && y%5 == 0){
- result = "FizzBuzz";}
- else if(y%3 == 0){
- result = "Fizz";}
- else if(y%5 == 0){
- result = "Buzz";
- }else {
-
- result = Integer.toString(y);}
- return result;
- }
- }
|