write a menu driven to accept a number from user . Check and display weather it is a prime number or automorphic no.
Answers
import java.io.*;
class check
{
public static void main(String args[]}throws IOException
{
int n , ch ;
InputStreamReader read=newInputStreamReader ( System.in);
BufferedReader in = new BufferedReader(read);
System.out.println( "Enter the no. " );
n = Integer.parseInt( in.readLine());
System.out.println("Press 1 to check prime no.");
System.out.println("Press 2 to check automorphic no. " );
ch = Integer.parseInt(in.readline());
switch(ch)
Case 1 :
{
for( int i = 1 ; i < = n ; i++ )
{
if( n% i = = 0 )
{
count + + ;
}
}
If ( count = = 2 )
{
System.out.println( " prime no. " );
}
else
{
System.out.println( " not a prime no. ");
}
}
break;
Case 2 :
{
int sq ;
sq = n * n ;
{
while ( sq < 10 );
{
int a = sq% 10 ;
}
}
if( a = = n )
{
System.out.println ( " automorphic no. " );
}
else
{
System.out.println( " not an automorphic no. " );
}
}
break;
default :
System.out.println( " Enter a valid choice " );
}
}