0% found this document useful (0 votes)
19 views2 pages

Menu Program

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

Menu Program

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.util.

*;
public class Menu_program
{
public static void main(String args[])
{
Scanner ab = new Scanner(System.in);
System.out.println("Choose any one of the following :- ");
System.out.println("1. Reverse a number which consists of three digits ");
System.out.println("2. Display the sum of even digits of a number which
consists of two digits ");
System.out.println("3. Input tgwo different two-digit number and display
the one which consists of prime digits");
System.out.println("Enter your choice (only the option number) = ");
int ch= ab.nextInt();
if(ch==1)
{
System.out.println("Enter a three-digit number= ");
int a= ab.nextInt();
int b= a%10;
int c= (a/10)%10;
int d= a/100;
int rn= (d*100)+(c*10)+b ;
System.out.println("The Reversed number= " +rn);
}
else if(ch==2)
{
System.out.println("Enter a two digit number= ");
int aa= ab.nextInt();
int aao= aa%10;
int aat= aa/10;
if(aao%2==0 && aat%2==0)
{
int s= aao+aat;
System.out.println("Sum of even numbers= " +s);
}
else
System.out.println("The numbers are not even");
}
else if(ch==3)
{
System.out.println("Enter a two-digit number= ");
int n= ab.nextInt();
System.out.println("Enter another two-digit number= ");
int nn= ab.nextInt();
int no= n%10;
int nt= n/10;
int nno= nn%10;
int nnt= nn/10;
if((no==2 || no==3 || no==5 || no==7) && (nt==2 || nt==3 || nt==5 ||
nt==7))
System.out.println("The number consisting of prime digits= " +n);
else if((nno==2 || nno==3 || nno==5 || nno==7) && (nnt==2 || nnt==3 ||
nnt==5 || nnt==7))
System.out.println("The number consisting of prime digits= " +nn);
else
System.out.println("None of the number consists of prime digits");
}
else
System.out.println("Invalid input");
}
}

You might also like