-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseries12.java
62 lines (62 loc) · 1.66 KB
/
series12.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import java.util.Scanner;
class series12//Buzz and GCD
{
void generateMenu()
{
System.out.println("What would you like to do ?");
System.out.println("1. Check if number is a Buzz number");
System.out.println("2. Find GCD of 2 numbers");
}
void BuzzNum()
{
Scanner sc = new Scanner(System.in);
int num;
System.out.println("Enter the number");
num=sc.nextInt();
if (num % 10 == 7 || num % 7 == 0)
{
System.out.println("Entered number " + num + " is a Buzz number.");
}
else
{
System.out.println("Entered number " + num + " is not a Buzz number.");
}
}
void GCD()
{
int num1, num2;
int hcf=0;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the first number");
num1=sc.nextInt();
System.out.println("Enter the second number");
num2=sc.nextInt();
for(int i=1;i<=num1;i++)
{
if(num1%i==0 && num2%i==0)
hcf=i;
}
System.out.println("The GCD is"+hcf);
}
public static void main()
{
Scanner sc= new Scanner(System.in);
series12 obj= new series12();
char choice;
int opt;
do
{
obj.generateMenu();
System.out.println("Enter your selection[1/2]");
opt=sc.nextInt();
if(opt==1)
obj.BuzzNum();
else if(opt==2)
obj.GCD();
else
return;
System.out.println("Would you like to continue[y/n]");
choice=(sc.next()).charAt(0);
} while(choice=='y');
}
}