-
Notifications
You must be signed in to change notification settings - Fork 0
/
src.java
39 lines (31 loc) · 887 Bytes
/
src.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.util.*;
public class FizzBuzz {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Input minimum number:");
int min = scan.nextInt();
System.out.println("Input maximum number:");
int max = scan.nextInt();
for(int value = min; value <= max; value++){
if(canFizz(value) & canBuzz(value)){
System.out.println("Fizz-Buzz");
}else if(canFizz(value)){
System.out.println("Fizz");
}else if(canBuzz(value)){
System.out.println("Buzz");
}else{
System.out.println(value);
}
}
}
public static boolean canFizz(int input){
boolean fizz = true;
if(input % 3 != 0) return false;
return fizz;
}
public static boolean canBuzz(int input){
boolean buzz = true;
if(input % 5 != 0) return false;
return buzz;
}
}