Question: Program: Authoring assistant (C++) (1) Write the function PrintString(). PrintString() accepts a string variable into a constant string parameter by reference. The function simply displays

Program: Authoring assistant (C++)

(1) Write the function PrintString(). PrintString() accepts a string variable into a constant string parameter by reference. The function simply displays a label "You entered: " and then the value of the string parameter using cout. This function does not return a value. (1 pt)

Ex:

Enter a sample text: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue!

You entered: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue!

(2) Write a PrintMenu() function, which has no parameters, The function outputs a menu of user options for analyzing/editing the string, and returns the user's entered menu option as a character. Each option is represented by a single lowercase character. If an invalid character is entered, continue to prompt for a valid choice.

Ex:

MENU c - Number of non-whitespace characters w - Number of words f - Find text r - Replace all !'s s - Shorten spaces q - Quit

Choose an option:

(3) Write the GetNumOfNonWSCharacters() function. GetNumOfNonWSCharacters() has a constant string parameter passed by reference. The function returns the number of characters in the string, excluding all whitespace.

Ex:

Number of non-whitespace characters: 181

(4) Write the GetNumOfWords() function. GetNumOfWords() has a constant string parameter passed by reference. The function returns the number of words in the string. Hint: Words end when a space is reached except for the last word in a sentence.

Ex:

Number of words: 35

(5) Write the FindText() function, which has two constant string parameters passed by reference. The first parameter is the text to look for and the second parameter is the user provided sample text. The function returns the number of times the first string is found in the second string. Hint: Remember, we are not looking for a position using the string find() method. We are looking for a number of times the search string is found.

Ex:

Enter a word or phrase to be found: more "more" instances: 5

(6) Write the ReplaceExclamation() function. ReplaceExclamation() has a string reference parameter and updates the string by replacing each '!' character in the string with a '.' character. ReplaceExclamation() DOES NOT output the string.

Ex.

Edited text: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue.

(7) Write the ShortenSpace() function. ShortenSpace() has a string reference parameter and updates the string by replacing all sequences of 2 or more spaces with a single space. ShortenSpace() DOES NOT output the string.

Ex:

Edited text: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!