Contact us - +12567847275

userInputText) << endl;
break;

case ‘r’:
cout << “”Edited text: “” << ReplaceExclamation(userInputText) << endl;
break;

case ‘s’:
cout << “”Edited text: “” << ShortenSpace(userInputText) << endl;
break;

case ‘q’:
return choice;
}
}
}

int main() {
char choice;
string userInputText;
cout << “”Enter a sample text:””<<>
getline(cin

#include

int GetNumOfNonWSCharacters(const string userInput) {
int j = 0;
for (unsigned int i = 0; i < userInput.size(); i++) {
if (userInput.at(i) != ‘ ‘ ) {
j++;
}
} return j;
}

int GetNumOfWords(const string userInput) {
int j = 1;
for (unsigned int i = 0; i < userInput.size(); i++) {
if (userInput.at(i) == ‘ ‘ && userInput.at(i + 1) != ‘ ‘) {
j++;
}
} return j;
}

int FindText(string word2Find,const string userInput) {
int instances = 0;
unsigned int letterCounter = 0;
for ( unsigned int i = 0; i < userInput.size(); i++) {
if (userInput.at(i) == word2Find.at(letterCounter)) {
letterCounter++;
if (letterCounter == word2Find.size()) {
letterCounter = 0;
instances++;
}
} else if (userInput.at(i) != word2Find.at(letterCounter)) {
letterCounter = 0;
}
} return instances;
}

string ReplaceExclamation(string& userInput) {
for (unsigned int i = 0; i < userInput.size(); i++) {
if (userInput.at(i) == ‘!’ ) {
userInput.at(i) = ‘.’;
}
}
return userInput;
}

string ShortenSpace(string& userInput) {
string ss;
for (unsigned int i = 0; i < userInput.size(); i++) {
if (i == userInput.length()-1) {
ss += userInput.at(i);
break;
}
if (userInput.at(i) == ‘ ‘ && userInput.at(i + 1) == ‘ ‘ ) {
continue;
} else {
ss += userInput.at(i);
}
} userInput = ss;
return userInput;
}

char PrintMenu(string userInputText) {
char choice;
string findWord;
while (true) {
cout << endl;
cout << “MENU” << endl;
cout << “c – Number of non-whitespace characters” << endl;
cout << “w – Number of words” << endl;
cout << “f – Find text” << endl;
cout << “r – Replace all !’s” << endl;
cout << “s – Shorten spaces” << endl;
cout << “q – Quit” << endl << endl;

cout << “Choose an option:”<<>
cin >> choice;

switch (choice) {

case ‘c’:
cout << “Number of non-whitespace characters: ” << GetNumOfNonWSCharacters(userInputText) << endl;
break;

case ‘w’:
cout << “Number of words: ” << GetNumOfWords(userInputText) << endl;
break;

case ‘f’:
cin.ignore();
cout << “Enter a word or phrase to be found:”<<>
getline(cin, findWord);
cout << “”” << findWord << “””” “” << “”instances: “” << FindText(findWord

Solution:

15% off for this assignment.

Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!

Why US?

100% Confidentiality

Information about customers is confidential and never disclosed to third parties.

Timely Delivery

No missed deadlines – 97% of assignments are completed in time.

Original Writing

We complete all papers from scratch. You can get a plagiarism report.

Money Back

If you are convinced that our writer has not followed your requirements, feel free to ask for a refund.