Analyzing digital java palindrome

 

//check whether the number is palindrome or not

/*
 * a number is said to be palindrome if, reverse of the number is same to 
 * that of real. for example, 121, 52025, 5885 etc..
 */
import java.util.Scanner;

public class Numbers {

    public static void main(String[] args) {
        int num, rev = 0;
        Scanner ip = new Scanner(System.in);
        System.out.print("Enter a number: ");
        Surely = ip.nextInt ();
        int temp = num;
        while (num> 0 ) {
             int matter whether% = 10 ;
            rev = (rev * 10) + rem;
            a = a / 10 ;
        }
        if (temp == rev)
            System.out.println("It is palindrome");
        else
            System.out.println("It is not a palindrome");
        ip.close();
    }
}



OUTPUT:
Enter a number: 12321
It is palindrome

 

Guess you like

Origin www.cnblogs.com/sea-stream/p/12143288.html