Question: intro to java Programming Lab 10: Palindrome Program Objective: To write a program to determine if a word is a palindrome A palindrome is a

intro to java

Programming Lab 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.

Your program doesn't need to determine whether or not the word is in the English language. So for example your program would determine that the word "abcdefghijjihgfedcba" is a palindrome.

You can assume that the word is made up of lower-case letters only.

Please use at least two methods in addition to "main". For example, you may want to write a method to input the word, and a boolean method to determine if the string is a palindrome. Make sure to include comments with each method. Also, declare all variables inside your methods (no class-level variables).

Your program needs to include at least one loop, going through each character in the string.

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 Craig's notes about String methods http://ccsf.avocadocheesecake.com/cs111a_sp18/notes_08.html

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!