| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import java.util.*;
- /**
- * 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
- x = 0;
- }
-
- /**
- * An example of a method - replace this comment with your own
- *
- * @param y a sample parameter for a method
- * @return the sum of x and y
- */
- public static String FizzBuzzGame(int number)
- {
- Scanner sc = new Scanner(System.in);
- number = sc.nextInt();
-
- if(number % 3 == 0 && number % 5 == 0){
- System.out.println("FizzBuzz");
- return "FizzBuzz";
- } else if(number % 3 == 0){
- System.out.println("Fizz");
- return "Fizz";
- } else if (number % 5 == 0){
- System.out.println("Buzz");
- return "Buzz";
- }
- return "Thank for playing";
- }
- }
|