{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

HW5.cpp - #include #include #include...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> #include <string> #include <cctype> using namespace std; int countWords(string words) { int length = words.length(); int count = 1; for (int size = 0; length > size; size++) { if (words[size] == ' '&& words[size - 1] != ' ') count++; } if (words[0] == ' ') count--; return count; } int countConsonants(string words) { int consonant = 0; for (int j = 0; j<words.length(); j++) { if (isalpha(words[j])) { if (words[j] != 'A' && words[j] != 'a' && words[j] != 'E' && words[j] != 'e' && words[j] != 'I' && words[j] != 'i' && words[j] != 'O' && words[j] != 'o' && words[j] != 'U' && words[j] != 'u') consonant++; } } return consonant; } int main() { string input, reverse; char select; cout << "Please enter a word, a sentence, or a string of numbers." << endl; cout << endl; getline(cin, input); do { cout << "USE THIS MENU TO MANIPULATE YOUR STRING" << endl; cout << "---------------------------------------" << endl; cout << "1) Inverse String" << endl; cout << "2) Reverse String" << endl; cout << "3) To Uppercase" << endl; cout << "4) Count Number Words" << endl; cout << "5) Count Consonants" << endl; cout << "6) Enter a Different String" << endl; cout << "7) Print the string" << endl; cout << "Q) Quit" << endl;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
cout << endl; cin >> select; cin.ignore();
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}