Question: Please do this in C++ and use good format. Also some explanatations for some confusing code would be appreciated. (3) Implement the function getNumOfNonWSCharacters(). getNumOfNonWSCharacters()
Please do this in C++ and use good format. Also some explanatations for some confusing code would be appreciated.
(3) Implement the function getNumOfNonWSCharacters(). getNumOfNonWSCharacters() has a constant string as a parameter and returns the number of characters in the string, excluding all whitespace. The function isspace(c) will be useful here. Use the following prototype: int getNumOfNonWSCharacters(const string usrStr)
4) Implement the function getNumOfWords(). getNumOfWords() has a constant string as a parameter and returns the number of words in the string. Hint: Words end when a space is reached, so if you see a space, and the character before it is not a space, then add 1 to your word count. The last word in the paragraph will likely not have a space after it, so just add an extra word to your total if the last character in the paragraph is not a space. Use the following prototype: int getNumOfWords(const string usrStr)
(5) Implement the function findText(), which has two strings as parameters. The first parameter is the text to be found in the user provided sample text, and the second parameter is the user provided sample text. The function returns the number of instances a word or phrase is found in the string. In main, if the user selects option f, prompt the user for a word or phrase to be found and then call findText(). Make sure the order of arguments in your call matches the order of the parameters. Also be sure there are no characters left in the read buffer before you try to read the user's search string. If there are, get rid of them with cin.ignore(). Use the following prototype: int findText(const string toFind, string usrStr)
(6) Implement the function replaceExclamation(). replaceExclamation() has a string parameter and updates the string by replacing each '!' character in the string with a '.' character. replaceExclamation() DOES NOT output the string. Call replaceExclamation() in main, and then output the edited string. Use the following prototype: void replaceExclamation(string& usrStr)
(7) Implement the function shortenSpace(). shortenSpace() has a string parameter and updates the string by replacing all sequences of 2 or more spaces with a single space. shortenSpace() DOES NOT output the string. Call ShortenSpace() in the PrintMenu() function, and then output the edited string. Use the following prototype: void shortenSpace(string& usrStr).
Use the following for (7):
for (i = 0; i < usrStr.size() - 1; i++) { if(isspace(usrStr.at(i)) && isspace(usrStr.at(i+1))) { usrStr.erase(i,1); i--; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
