due at midnight on +40
The goal of this assignment is to continue defining and using functions, and to work with strings. We will also revisit the full-line input method used in assignment 7:
string input; // declare variable
getline(cin, input); // get one line of text from user
Your program should repeatedly ask the user to type a one-line word or phrase. If they type end
, then the program should stop. After they enter their phrase, your program:
Here is a sample run:
Enter your text (or end): 2013
Backwards: 3102
Your input has 0 vowels.
Enter your text (or end): caravan
Backwards: navarac
Your input has 3 vowels.
Enter your text (or end): 1991
Backwards: 1991
Your input has 0 vowels.
Palindrome!
Enter your text (or end): ABBA
Backwards: ABBA
Your input has 2 vowels.
Palindrome!
Enter your text (or end): balloollab
Backwards: balloollab
Your input has 4 vowels.
Palindrome!
Enter your text (or end): balloon
Backwards: noollab
Your input has 3 vowels.
Enter your text (or end): end
Your program must use at least two functions besides main
. Here are the three that I used:
bool is_palindrome(string word);
int count_vowels(string word);
void print_backwards(string word);
This time, the content of the main
function is up to you.