how to write an application that reads in a five digit integers and determine whether the number is as palindromes or not e.g 12321,11611.If the number is not five digit long, display an error dialog, allow the user to enter a new value.

Recommended Answers

All 7 Replies

With a text editor, of course.

Why don't you write a bit of pseudocode that outlines the general process the program must follow to complete the needed steps and post it here if you need some help with portions of it?

Try this. It can be made a lot more efficient. Next time please put at least a psuedo code.

import java.io.*;
class Pal
{
public static void main(String args[]) throws IOException
{
int num,rev=0,temp;
boolean flag=true;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
while(flag)
{
System.out.println("Enter a number:");
num=br.readline();
//To check if it is a 5 digit number
if(num/10000>=1 && num/10000<10)
flag=false;
}
temp=num;
//Reversing the number
while(num!=0)
{
rev=rev*10+num%10;
num=num/10;
}
if(rev==temp)
System.out.println("It is a palindrome");
else
System.out.println("Not palindrome");
}
}
commented: Don't just hand out homework anwers. -2

Also put an error message in the if block where u check for 5 digit numbers

Try this. It can be made a lot more efficient. Next time please put at least a psuedo code.

Handing students who have shown no effort at all on their assignment the answer is against the spirit of this forum, as evidenced by this prominent post at the top of the forum: http://www.daniweb.com/forums/announcement9-2.html

You are rewarding laziness and fostering incompetence.

I have to determine whether the word enter is a palindrome or not

That's a statement, not a question. Start a new thread if you have a specific question about the code that you have written so far.

If you haven't written any code yet then you haven't really put any effort into the assignment and probably shouldn't expect anyone to else to expend any time on it either.

given the already provided answer, did he even read the rest of the thread?
Does he even know what a palindrome is?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.