Palindrome Number : Java : BlueJ

Objective :


The class Palindrome checks if the Number Entered reads equally  from Left to Right and Right to left For example 121. The number 121  is deduced as Follows : ((1*10)+2)*10+1)


BlueJ Program Screenshot :



Java Program Source Code :

/**
 * The class Palindrome checks if the Number Entered reads equally  from Left to Right and Right to left For example 121.
 * The number 121  is deduced as Follows : ((1*10)+2)*10+1)
 * @author SHANTANU KHAN
 * @mail shantanukhan1995@gmail.com
 * @website 0code.blogspot.com 
 * Program Type : BlueJ Program - Java
 */
import java.io.*;
public class Palindrome_Number
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    static int number=0;
    
    private void input()throws Exception
    {
        System.out.print("Enter the Number to be Checked to be Palindrome : ");
        number=Integer.parseInt(br.readLine());
    }
    
    public boolean isPalindromeNumber(int num)
    {
        int temp=num,palin=0;
        while(num%10!=0)
        {
            palin*=10; palin+=(num%10);
            num/=10;
        }
        if(temp==palin) return true;
        else return false;
    }
    
    public static void main(String args[])throws Exception
    {
        Palindrome_Number obj=new Palindrome_Number(); obj.input();
        if(obj.isPalindromeNumber(number))  System.out.println("The Number "+number+" is Palindrome");
        else    System.out.println("The Number "+number+" is Not Palindrome");
    }
}

    


© Shantanu Khan 0code ® Palindrome Number