Posted by : Unknown Sunday, 28 June 2015


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class palindrome
{
    public static void main(String[] args)
    {
        try
   {
            System.out.print("Enter a number: ");
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String num=br.readLine();
            int no=Integer.parseInt(num);
            int temp=no;
            int digit=0,ld;
            while(no!=0)
            {
                ld=no%10;
                digit=digit*10+ld;
                no=no/10;
            }
            if(temp==digit)
            {
                System.out.println("Palindrome number");
            }
            else
     {
                System.out.println("Not a palindrome number");
            }
        }
   catch (IOException | NumberFormatException ex)
   {
       }
    }
}

Output:

Enter a number: 123
Not a palindrome number

Enter a number: 12321
Palindrome number

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Welcome to My Blog

Translate

Popular Post

Total Pageviews

Blog Archive

- Copyright © Learning Java Program - Powered by Blogger -