Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A palindrome is a phrase (i.e., a string of characters) that reads the same forward and backward (ignoring spaces, punctuation, and capitalization). For example: A

image text in transcribedimage text in transcribedimage text in transcribed

A palindrome is a phrase (i.e., a string of characters) that reads the same forward and backward (ignoring spaces, punctuation, and capitalization). For example: A man, a plan, a canal: Panama! is a palindrome. This lab consists of two programs that determine if a string represents a palindrome. The programs use two different string representations or types and different input schemes. You may use any code that you wish from the example programs as a part of either of your programs. Do not include code from the examples that does not pertain to these labs Test Cases Valid Palindrome a man a plan a canal panama Invalid Palindrome a man a plan a canax panama Valid Palindrome never odd or even Invalid Palindrome never odd or ven Program 1: Palindromes With The string Class Program 1 Requirements 1. Name your program palindrome.cpp 2. All strings in the program are implemented as instances of the C++ string class 3. Prompt for the user to enter a potential palindrome 4. Read the user input in to an instance of the string class (see string /Oe for an example) a. The test input will NOT contain punctuation characters (periods, commas, exclamation or question marks), eto b. The test input will consist of only one case (i.e., it will not contain a mix of upper and lower case letters) C. The test input will contain spaces, which you must remove (see the code fragment beloww) 5. Test the string to see if it is a palindrome (follow either of the two examples in 8.3.4 palnumber.cppe) 6. Write a message to the screen stating that the input was or was not a valid palindrome 7. The program terminates after printing the message no prompts, loops, or pauses Removing Spaces From A String It is probably easiest to first remove all of the spaces from the string before testing it to see if it is a palindrome. The following code fragment (which you may use in your program) will remove the spaces from a string object: for (int i e; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions