Question: #include #include #include using namespace std; void readText(string text) { cout < < Enter a line of text or just hit enter to end the
#include
void readText(string text) { cout << "Enter a line of text or just hit enter to end the program: "; getline(cin, text);
}
void readInTextCount(string &text, int &vowels, int &consonants, int &words) { vowels = 0; consonants = 0; words = 1 ; int textCount; char counter = text.at(textCount); while (textCount <= text.length()-1) {
if (counter >= 'a' || counter >= 'e' || counter >= 'i' || counter >= 'o' || counter >= 'u' || counter >= 'A' || counter >= 'E' || counter >= 'I' || counter >= 'O' || counter >= 'U') { ++vowels; } else if ((counter >= 'a' && counter <= 'z') || (counter >= 'A' && counter <= 'Z')) { ++consonants; } if (counter >= ' ') { ++words; } textCount++;
} } void displayFun(string text, int vowels, int consonants, int words) {
cout << text << endl; cout << "Has: " << endl; cout << setw(18) << "Consonants: " << consonants << endl;
cout << setw(14) << "Vowels: " << vowels << endl; cout << setw(13) << "Words: " << words + 1 << endl; }
int main() { string text; int vowels = 0, consonants = 0, words = 0; char counter = 0; readText(text); readInTextCount(text, vowels, consonants, words); displayFun(text, vowels, consonants, words); if(text!= "") { cout << "Goodbye!" << endl; } else { cout << "Enter another line of text or just hit enter to end the program: "; getline(cin, text); readInTextCount(text, vowels, consonants, words); displayFun(text, vowels, consonants, words); }
return 0; }
*******************************************
what did i do wrong?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
