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
You have an asp. Net web application running on a web-farm that does not use sticky sessions - so the requests for a session are not guaranteed to be served the same machine. Occasionally, the users get error message validation of view state mac failed. What could be one reason that is causing this error?
What is the difference between var and let?
How to submit a form using JavaScript by clicking a link?
What does 3 dots mean in javascript?
Explain the difference between javascript and an asp script.
Name the two functions that are used to create an HTML element dynamically?
How Can I get facebook fans/likes?
How is a relation not a function?
How do you organize your JavaScript code?
What is the use of a set object in javascript?
Explain the different types of pop-up boxes you can create in JavaScript.
How to remove the event listener?
What is the use of a number object in javascript?
What does the following statement declares?
Can I declare a variable as CONSTANT in JavaScript?