#include // This program reads a string of characters // terminated by a newline character // and counts the number of vowels in the string. // The vowels are A, E, I, O, and U. // Let's not worry about Y. int main() { char c; int total_vowels, total_nonvowels; cout << "Enter a line of text terminated by 'enter': "; total_vowels = total_nonvowels = 0; // get first character cin >> c; while (c != '.') { // add to a total if the character being processed is a vowel. switch (c) { case 'a': case 'e': case 'i': case 'o': case 'u': case 'A': case 'E': case 'I': case 'O': case 'U': total_vowels ++; break; default: total_nonvowels ++; } // get next character cin >> c; } cout << "The number of vowels is " << total_vowels << endl; cout << "The number of nonvowels is " << total_nonvowels << endl; }