Palindrome number Program or not in java

Palindrome Number or not in java:

A palindrome number is a number that is same number after reverse order.For example 535, 121, 34643, 323, 151, 48584 are the
palindrome numbers.

import java.util.Scanner;
public class palindrome {
public static void main(String args[]){
int a,reminder,reverse=0,n;
System.out.print(“enter the a value: “);
Scanner h=new Scanner(System.in);
a=h.nextInt();
n=a;
while(a!=0){
reminder=a%10;
reverse=reverse*10+reminder;
a=a/10;
}
if(n==reverse)
System.out.println(“the given number is a palindrome : “+n);
else
System.out.println(“the given number is not a palindrome: “+n);
}
}

Output
enter the a value: 845
the given number is not a palindrome: 845

Related Programs Below:
Write a program the given number is even or odd in java?
Write a program for the given number is Fibonacci or not in java?
Prime numbers in Java?
Palindrome number Program in java?
Armstrong Number or not in Java?
Write a program for the given number is strong Number or Not  in java?
Write a program swapping two numbers without using third variable in java ?
Swapping of two numbers using third variable in java?

Leave a Reply

Your email address will not be published.