Write a program to accept a number from the user and check whether it is a buzz number or to accept any two numbers and print GCD (greatest common divisor)
Answers
Answered by
2
hey mate ur answer is in attachment
hope it help u
hope it help u
Attachments:
Answered by
6
JAVA:-
Explanation:
import java.util.*;
class Brainly
{
static void main()
{
Scanner sc=new Scanner(System.in);
int ch,n,r=0,a,b;
System.out.println(“MENU”);
System.out.println(“1.Buzz Number”);
System.out.println(“2.GCD”);
System.out.println(“Enter your choice:”);
ch=sc.nextInt();
switch(ch)
{
case 1:
System.out.println(“Enter a number:”);
n=sc.nextInt();
if(n%7==0 || n%10==7)
System.out.println(“Buzz Number”);
else
System.out.println(“Not a Buzz Number”);
break;
case 2:
System.out.println(“Enter 2 numbers:”);
a=sc.nextInt();
b=sc.nextInt();
for(r=a%b;r>0;r=a%b)
{
a=b;
b=r;
Computer Applications – IX (ICSE Course) Answers 156
}
System.out.println(“GCD=”+b);
break;
default:
System.out.println(“Invalid choice”);
}
}
Similar questions