User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 429,786 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,895 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 354 | Replies: 4
Reply
Join Date: Jul 2008
Posts: 7
Reputation: ricss_madara is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ricss_madara ricss_madara is offline Offline
Newbie Poster

application can read palindrome number.

  #1  
Jul 25th, 2008
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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2007
Location: USA
Posts: 2,868
Reputation: Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all 
Rep Power: 12
Solved Threads: 284
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is online now Online
Posting Maven

Re: application can read palindrome number.

  #2  
Jul 25th, 2008
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?
Reply With Quote  
Join Date: Jul 2008
Posts: 10
Reputation: @bhi is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
@bhi @bhi is offline Offline
Newbie Poster

Re: application can read palindrome number.

  #3  
Jul 25th, 2008
Try this. It can be made a lot more efficient. Next time please put at least a psuedo code.

  1. import java.io.*;
  2. class Pal
  3. {
  4. public static void main(String args[]) throws IOException
  5. {
  6. int num,rev=0,temp;
  7. boolean flag=true;
  8. BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  9. while(flag)
  10. {
  11. System.out.println("Enter a number:");
  12. num=br.readline();
  13. //To check if it is a 5 digit number
  14. if(num/10000>=1 && num/10000<10)
  15. flag=false;
  16. }
  17. temp=num;
  18. //Reversing the number
  19. while(num!=0)
  20. {
  21. rev=rev*10+num%10;
  22. num=num/10;
  23. }
  24. if(rev==temp)
  25. System.out.println("It is a palindrome");
  26. else
  27. System.out.println("Not palindrome");
  28. }
  29. }
Reply With Quote  
Join Date: Jul 2008
Posts: 10
Reputation: @bhi is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
@bhi @bhi is offline Offline
Newbie Poster

Re: application can read palindrome number.

  #4  
Jul 25th, 2008
Also put an error message in the if block where u check for 5 digit numbers
Reply With Quote  
Join Date: May 2007
Location: USA
Posts: 2,868
Reputation: Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all 
Rep Power: 12
Solved Threads: 284
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is online now Online
Posting Maven

Re: application can read palindrome number.

  #5  
Jul 25th, 2008
Originally Posted by @bhi View Post
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the Java Forum

All times are GMT -4. The time now is 4:12 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC