1234567891011121314151617181920212223242526272829303132333435363738 |
-
- /**
- * 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(){
- }
-
- public String result(int input) {
-
-
- if (input % 3 == 0 && input % 5 == 0) {
- return "FizzBuzz";
- }
- else if(input % 3 == 0) {
- return "Fizz";
- }
- else if (input % 5 == 0) {
- return "Buzz";
- }
- else {
- return String.valueOf(input);
- }
- }
-
-
- }
|