neeeeeed help in java program

Page 1 of 1

1 Replies - 616 Views - Last Post: 22 March 2009 - 04:19 PM Rate Topic: -----

#1 ENG.A  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 22-March 09

neeeeeed help in java program

Posted 22 March 2009 - 04:10 PM

Using the template programs Palindrome.java and PalindromeTest.java, write a Java application that reads in a five-digit integer and determines whether it is a palindrome (defined below). If the number is not five digits long, display an error message and allow the user to enter a new value.

A palindrome is a sequence of characters that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611.

Sample Output

Enter a 5-digit number: 1234
Number must be 5 digits
Enter a 5-digit number: 123456
Number must be 5 digits
Enter a 5-digit number: 54345
54345 is a palindrome!!!

Problem-Solving Tips
a) Determine the number of digits in the value input by the user and assign the result to digits. Use a while loop to determine whether the user input contains the proper number of digits. In the condition, determine whether digits is equal to five. If not, input a new value from the user and determine whether the new value contains the proper number of digits. When the number of digits is five, the loop should terminate.

B) Use division and remainder calculations to obtain the separate digits. For a five-digit number to be a palindrome the first and fifth digits must be the same and the second and fourth digits must be the same.

c) Be sure to follow the spacing and indentation conventions mentioned in the text

Is This A Good Question/Topic? 0
  • +

Replies To: neeeeeed help in java program

#2 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 727
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

Re: neeeeeed help in java program

Posted 22 March 2009 - 04:19 PM

[rules][/rules]
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1