-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuzznumber.java
42 lines (34 loc) · 1.31 KB
/
buzznumber.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
40
41
42
import java.util.*;
// import java.util.Scanner;
//create BuzzNumberExample class to check whether the given number is Buzz number or not
class buzznumber {
static boolean checkNumber(int number) {
// check whether the number ends with 7, is divisible by 7 or not
if (number % 10 == 7 || number % 7 == 0)
return true; // returns true when the number is Buzz
else
return false; // returns flase when the number is not Buzz
}
// main() method start
public static void main(String args[]) {
int n1, n2;
// create scanner class object to get input from user
Scanner sc = new Scanner(System.in);
// show custom message
System.out.println("Enter first number");
// store user entered value into variable n1
n1 = sc.nextInt();
// show custom message
System.out.println("Enter second number");
// store user entered value into variable n2
n2 = sc.nextInt();
if (checkNumber(n1))
System.out.println(n1 + " is a Buzz number");
else
System.out.println(n1 + " is not a Buzz number");
if (checkNumber(n2))
System.out.println(n2 + " is a Buzz number");
else
System.out.println(n2 + " is not a Buzz number");
}
}