Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I really need help with the code for this, in C++ please, I know there's a similar question but the answer isn't correct :[ A

I really need help with the code for this, in C++ please, I know there's a similar question but the answer isn't correct :[ A palindrome is a string that reads the same forwards and backwards (ignoring spaces, punctuation, and capitalization). Examples are the familiar ``If I had a hi-fi,'' the grander ``A man, a plan, a canal, Panama,'' and ``Some men interpret nine memos.'' So the goal: Design, implement, document, and test a program that reads a line of input from the terminal window and reports whether or not that line is a palindrome. The object of this project is to review and exercise C++ in general and arrays in C++ in particular. Input: An input line may contain any characters, though only letters are relevant in palindromes. Upper-case and lower-case letters are considered the same; 'A' = 'a'. For convenience, the maximum length of the input is 80 characters. Output: The program will prompt for the input line---a candidate palindrome---and will report whether or not the line is a palindrome. Errors: The program may assume that the input is as described. It need not detect any errors. Example: Several runs of the program might look like this: csh> pal Enter a line that might be a palindrome: Madam I'm Adam. The string is a palindrome. csh> pal Enter a line that might be a palindrome: Able was I ere I saw Elba. The string is a palindrome. csh> pal Enter a line that might be a palindrome: Go hang a salami, I'm a lasagna hog. The string is a palindrome. csh> pal Enter a line that might be a palindrome: This is another candidate string. The string is NOT a palindrome. PLEASE INCLUDE/ REQUIRED TO BE A COMPLETE ANSWER: Use arrays of characters to hold any strings that the program manipulates, and terminate strings within those arrays with the null character '\0'. Include at least one function. Helpful direction/ tips: Read the input one character at a time and preserve only the letters; they're all that's interesting. Note the iostream.h function get( ), which reads exactly one character, including the blank. The following loop reads all the characters in an input line, one at a time, into the variable ch. char ch; . . . cin.get(ch); while ( ch >= ' ' ) { < Do something with ch. > cin.get(ch); } When designing tests for your program, note that a string that contains no letters is a palindrome, as is an empty string.

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

Students also viewed these Databases questions

Question

What magazine and ads did you choose to examine?

Answered: 1 week ago