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

Info icon This 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;
Image of page 1

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern