In this lab, we will be playing with c++ strings and vectors You will practice:
A palindrome is a string that is the same when read left to right as when read right to left. Let's write a program that determines if an arbitrary string is a palindrome. Assume that the string can have blanks, punctuation, capital letters and lower case.
A man, a plan, a canal, Panama.
Able was I 'ere I saw Elba.
Madam, I'm Adam.
Racecar
Enter your palindrome or type quit:
A man, a plan, a canal, Panama.
Enter your palindrome or type quit:
Be at a time I emit a beat
Enter your palindrome or type quit:
Racecar
Enter your palindrome or type quit:
A lad named E. Mandala
Enter your palindrome or type quit:
A Toyota's a Toyota
Enter your palindrome or type quit:
>Race and tell a dancer
Enter your palindrome or type quit:
quit
Palindromes:
A man, a plan, a canal, Panama.
Racecar
A lad named E. Mandala
A Toyota's a Toyota
NOT Palindromes:
Be at a time I emit a beat
Race and tell a dancer
If the clean string equals the reverse, it is a palindrome
Otherwise it is not…
Make sure not to change the original string!
Follow the model that we went over together in class. use the algorithm
above and call your prepocessing functions from the isPalindrome
function
// ToDo: Declare your functions and provide good comments on the prototypes.
// ToDo: Implement your functions. Remember to provide good comments on them.
Submit to autograder: https://storm.cis.fordham.edu
// ToDo: Remember to declare your functions and provide good comments on both
// prototypes and function headers.
#include <iostream>
// ToDo: Add include files
using namespace std;
int main() {
// ToDo: Declare two vectors of strings to save the input strings: palindromes, not_palindromes.
// ToDo: Implement a loop to read in the palindrome strings using getline until the user quits.
// ToDo: In the loop, call the isPalindrome function on the input string and store it in the
// palindromes vector if true and the notPalindromes vector if false.
// ToDo: After exiting the loop, print the list of palindromes under a Palindrome heading and
// the list that are not palindromes under a Not Palindrome heading.
}
Hints
Submission