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
What is enum with example?
How to set a html document's background color?
Is javascript server side or client side?
How to disable an html object ?
What is the importance of javascript?
What is webpack used for?
How to get value from a textbox?
Should you disable javascript?
What are the four basic data structures in javascript?
What kind of conditional statements does JavaScript support?
Why javascript is dangerous?
List some features of javascript.
What is a Typed Language?
Explain with an example the use of event handlers in javascript.
What is the context in javascript?