Computer Science, asked by shambhaviagrahari1, 3 months ago

write a menu driver program in java to accept the choice in 1 and 2 and display the following accept a number whether it is amstrong number or not and to accept and check for the prime number​

Answers

Answered by mohammadadnan7
1

Answer:

import java.util.*;

class Menu

{

public static void main (String args [])

{

Scanner sc=new Scanner (System.in);

int n,ch,i;

System.out.println("Menu");

System.out.println(" 1. for amstrong number");

System.out.println(" 2. for prime number ");

System.out.println("enter your choice");

ch=sc.nextInt();

System.out.println("enter a number");

n=sc.nextInt();

switch(ch)

{

case 1:

break;

case 2:

int c=0;

for(i=1;i<=n;i++)

{

if(n%i==0)

{

c++;

}

if(c==2)

System.out.println("prime number");

else

System.out.println("not a prime number");

}

break;

default:

System.out.println("wrong choice");

break;

}

}

}

bro tell me what is Armstrong number

Similar questions