//press 1. for Reverse for a given number.
//press 2. for check given number is palindrom or not
package javaprogram;
import java.util.Scanner;
public class ReversePalindrom
{
public static void main(String[] args)
{
System.out.println("press 1. for Reverse for a given number.");
System.out.println("press 2. for check given number is palindrom or not.");
System.out.println("Enter your choice..");
int ch;
Scanner s=new Scanner(System.in);
ch=s.nextInt();
if(ch==1)
{
rev();
}
else if(ch==2)
{
palindrom();
}
else
{
System.out.println("Invalid Number...");
}
}
static void rev()
{
int r=0,rev1=0;
System.out.println("Enter any Number.. ");
Scanner s=new Scanner(System.in);
int n=s.nextInt();
while(n!=0)
{
r=n%10;
rev1=rev1*10+r;
n=n/10;
}
System.out.println("Reverse..> "+rev1);
}
static void palindrom()
{
int r=0,rev1=0,org=0;
System.out.println("Enter any Number.. ");
Scanner s=new Scanner(System.in);
int n=s.nextInt();
org=n; //stored original values in org variable
while(n!=0)
{
r=n%10;
rev1=rev1*10+r;
n=n/10;
}
if(rev1==org)
{
System.out.println("Number is palindrom.> "+org);
}
else
{
System.out.println(org+" is not palindrom");
}
}
//press 1. for Reverse for a given number. //press 2. for check given number is palindrom or not
package javaprogram;
import java.util.Scanner;
public class ReversePalindrom {
}