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 get the contents of an input box using javascript?

532


What is JavaScript?

677


What data types are supported in Javascript?

521


How do I add a javascript event handler to an html page element?

475


a code in vb script, which creates a table of 5*2 in html this is a static table, one more same dynamic table, as we give input the table should get created.

1097






Explain promise in javascript?

440


What are the data types in js?

488


Why javascript is so popular?

458


What do you use javascript for?

497


what is lazy fetching in hibernate

1532


Define unescape() and escape() functions?

501


Explain typecasting in javascript?

488


What are the characteristics of javascript ‘strict mode’?

483


What is scope javascript?

557


what are the differences between as2 and as3?

2925