MIT-Curricular/OOP/Java/Lab/Week1/Palindrome.java

24 lines
585 B
Java
Raw Normal View History

2024-08-05 01:06:30 +05:30
class Palindrome
{
public static void main(String args[])
{
int a,i,c,temp,rev;
a = Integer.parseInt(args[0]);
temp = a;
rev = 0;
while(temp!=0)
{
c = temp%10;
rev = rev*10 + c;
temp = temp/10;
}
if(rev == a){
System.out.println("The number is a palindrome.");
}else{
System.out.println("The number is not a palindrome.");
}
}
}