Write a program that inputs a 5-digit integer from the
keyboard and prints if the input number is a palindrome or
not. A palindrome is a number which has the same digit from
either end.
Answer Posted / vinit
import java.io.*;
public class HelloWorld{
public static void main(String []args)throws IOException{
//System.out.println("Hello World");
int n;
int t;
int cpy;
int r,rev;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
t=Integer.parseInt(br.readLine());
while(t!=0)
{rev=0;
n=Integer.parseInt(br.readLine());
cpy=n;
while(n!=0)
{
r=n%10;
n=n/10;
rev=(rev*10)+r;
}
if(rev==cpy)
{System.out.println("palindrome");
t--;
continue;}
else{
System.out.println("not Palindrome");t--;
continue;
}
}
}
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How to remove duplicate values from a javascript array?
what is the different between html and java?why the java is required in internet?
What is difference between javascript and jscript?
What is a global variable in programming?
How to toggle display an html element?
How to create multiline strings in javascript?
What is the purpose of local variables?
What close() does in javascript?
just for testing
How to get value of an element by class in javascript ?
How to use external JavaScript file?
How use javascript html?
In which location cookies are stored on the hard disk?
What are the advantages of using external javascript?
Is javascript client side or server side?