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


Please Help Members By Posting Answers For Below Questions

How to remove duplicate values from a javascript array?

588


what is the different between html and java?why the java is required in internet?

1787


What is difference between javascript and jscript?

518


What is a global variable in programming?

579


How to toggle display an html element?

631






How to create multiline strings in javascript?

571


What is the purpose of local variables?

528


What close() does in javascript?

576


just for testing

1819


How to get value of an element by class in javascript ?

578


How to use external JavaScript file?

642


How use javascript html?

555


In which location cookies are stored on the hard disk?

586


What are the advantages of using external javascript?

553


Is javascript client side or server side?

576