The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
INTRODUCTION We have described input and output of individual characters and we have mentioned the character functions that the library cctype provides. We have recently introduced and exercised arrays and their passage as parameters. This project applies all these ideas.
A palindrome is a string that reads the same forwards and backwards (ignoring spaces, punctuation, and capitalization). Examples are the familiar "Madam, I'm Adam" and the grander "A man, a plan, a canal, Panama."
DESCRIPTION In this project, you will write a program that determines and reports if an input string is a palindrome. INPUT The program will read an input line of characters. Any printable characters may appear in the input. The maximum length of the input is 80 characters. OUTPUT The program will prompt for the input line and will report whether or not the string that is input is a palindrome. ERRORS Your 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:
> pal
Enter a line that might be a palindrome:
Madam, I'm Adam.
The string is a palindrome.
> pal
Enter a line that might be a palindrome:
Able was I ere I saw Elba.
The string is a palindrome.
> pal
Enter a line that might be a palindrome:
Go hang a salami; I'm a lasagna hog.
The string is a palindrome.
> pal
Enter a line that might be a palindrome:
This is another candidate string.
The string is NOT a palindrome.
OTHER REQUIREMENTS Store the relevant characters (that is, letters) in order in an array, then examine that array to determine if the input string is a palindrome. Write functions to: (1) read the input line, keeping only its letters; (2) make sure all letters in a string are upper case; and (3) determine if the letters form a palindrome. HINTS The end-of-line character is not printable, so its ASCII value is less than that of the blank. Thus, this code will read an input line (assume appropriate declarations):
cin.get(ch);
while ( ch >= ' ' )
{
Process the character in ch.
cin.get(ch);
}
Don't forget to count the letters as they are read in. HAND IN Hand in the following: