Click to See Complete Forum and Search --> : HELPPPP palindrom problem


shanna
09-26-2002, 10:56 PM
we are going to read in a five digit integer and determine if it is a palindrome.
A palindrome is a number or text phrase that reads the same backwards as
forwards. For example each of the following 5 digit numbers are palindromes:
12321, 55555, 45554, 11611.

Your program should look something like this:

Please enter a 5 digit integer:

123

123 is not five digits in length, please try again.

Please enter a 5 digit integer:

12341

12341 is NOT a palindrome.

Note the program should first check to make sure the user has entered a five
digit number.

Hint: Use the integer division and modulus operators to separate the number
into its individual digits. For example to get the last digit from 1257 I
use the modulus operator:

1257 % 10 is equal to 7.

Run the program with four carefully selected test cases that test as much
as the logic as possible. For example you will need to make one of the test
cases an invalid number so that you can test the code that asks the user
to try again.