Question
Write a program that prompts the user for a sentence and outputs if the sentence was a palindrome or not. The program should keep on
Write a program that prompts the user for a sentence and outputs if the sentence was a palindrome or not. The program should keep on prompting the user for sentences until the user says differently!
Pseudocode:
- Prompt the user for the sentence to check
- Convert the sentence to all lowercase (or all uppercase) characters.
- Create a new string that will include only the alphabetic characters of the original sentence (no spaces/punctuation) Hint: use a for-loop
- Create a new string with the reverse version of the previous string Hint: use a for-loop (you saw this already in Part3 of this lab)
- Compare the two strings to make the decision
- Print the decision
- Repeat if the user says so
SAMPLE OUTPUT Welcome to the palindrome checker program! Enter a sentence: Never odd or even! This is a palindrome! Do you want to continue (yeso)? yes Enter a sentence: Hello world This is not a palindrome! Do you want to continue (yeso)? Yes Enter a sentence: racecar This is a palindrome! Do you want to continue (yeso)? yeah Enter a sentence: Madam, I'm Adam This is a palindrome! Do you want to continue (yeso)? No GoodbyeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started