Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

import java.util.

*;
class Revnum2
{
int Palin()
{
Scanner sc = new Scanner(System.in);
int n,r,sum=0,t,e;
System.out.println("Enter any number to check Palindrome");
n = sc.nextInt();
t=n;
while(n>0)
{
r = n%10;
sum = sum*10+r;
n = n/10;
}
if(t==sum)
return 1;
else
return 0;
}
int Arm()
{
Scanner sc = new Scanner(System.in);
int n,r,sum=0,t,m;
System.out.println("Enter any number to check Armstrong");
n = sc.nextInt();
t=n;
while(n>0)
{
r = n%10;
sum = sum+(r*r*r);
n = n/10;
}
if(t==sum)
{
return 1;
}
else
{
return 0;
}
}
int Auto()
{
Scanner sc = new Scanner(System.in);
int n,p,k,c=1,d;
System.out.println("Enter any number to check Automorphic");
n = sc.nextInt();
p=n;
k=n;
while(p>10)
{
p=p/10;
c=c*10;
}
k=k*k;
if(k%c==n)
{
return 1;
}
else
{
return 0;
}
}

public static void main(String args[])


{
Scanner sc = new Scanner(System.in);
int Choice;
System.out.println("Enter your choice");
System.out.println("Press 1 for Armstrong and 2 for Palindrome and 3 for
Automorphic");
Choice = sc.nextInt();
Revnum obj = new Revnum();
switch(Choice)
{
case 1:
int d = obj.Arm();
if(d==1)
{
System.out.println("Armstrong number");
}
else
{
System.out.println("Not Armstrong");
}
break;
case 2:
int e= obj.Palin();
if(e==1)
{
System.out.println("Palindrome number");
}
else
{
System.out.println("Not");
}
break;
case 3:
int m = obj.Auto();
if(m==1)
{
System.out.println("Automorphic number");
}
else
{
System.out.println("Not");
}
break;
default:
System.out.println("Wrong Input");
}
}
}

You might also like