Homework 10: Palindrome Program

Objective: To write a program to determine if a word is a palindrome

A palindrome is a word that is spelled the same forward and backward, such as "radar", "madam", or "abba" Your program should ask the user to enter a word, and then tell the user whether or not that word is a palindrome.

Here is some sample output from the program:

Please enter a word: radar
The word you entered, 'radar' is a palindrome.


Please enter a word: abccba The word you entered: 'abccba' is a palindrome.
Please enter a word: abcddxba The word you entered: 'abcddxba' is not a palindrome.
Hint: To check to see if the last letter of a string named s is the letter 'e' you would write:
if(s.charAt(s.length()-1) == 'e')

For more notes and information on manipulating strings, see Chapter 2 part 2.

Return to main CS 111A page