Question

14.18 Homework7 P2: Authoring assistant

(1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string./n(2) Implement the PrintMenu() function to print the following command menu.

Ex:

MENU

c Number of non-whitespace characters

W-

Number of words

f

Fix capitalization

-

I Replace all !'s

9 - Quit

(3) Implement the ExecuteMenu() function that takes 2 parameters: a character representing the user's choice and the user provided

sample text. ExecuteMenu() performs the menu options, according to the user's choice, by calling the appropriate functions described

below.

(4) In the main() function, call PrintMenu() and prompt for the user's choice of menu options for analyzing/editing the string. Each option is

represented by a single character.

If an invalid character is entered, continue to prompt for a valid choice. When a valid option is entered, execute the option by calling

ExecuteMenu(). Then, print the menu, and prompt for a new option. Continue until the user enters 'q'. Hint: Implement Quit before

implementing other options./nEx:

MENU

с

Number of non-whitespace characters

W-

Number of words

f

Fix capitalization

I- Replace all !'s

q Quit

Choose an option:

(5) Implement the GetNumOfNonWSCharacters() function. GetNumOfNonWSCharacters() has a constant string as a parameter and

returns the number of characters in the string, excluding all whitespace. Hint: Using fgets() to read input will cause the input string to have a

newline character at the end. The newline character should not be counted by GetNumOfNonWSCharacters(). Call

GetNumOfNonWSCharacters() in the ExecuteMenu() function, and then output the returned value.

Ex:/nEnter 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!

MENU

c - Number of non-whitespace characters

W-

Number of words

f - Fix capitalization

r Replace all !'s

q Quit

Choose an option:

с

Number of non-whitespace characters: 181

(6) Implement the GetNumOfWords() function. GetNumOfWords() has a constant string as a parameter and returns the number of words

the string. Hint: Words end when a space is reached except for the last word in a sentence. Call GetNumOfWords() in the ExecuteMenu()

function, and then output the returned value.

Ex:/nNumber of words: 35

(7) Implement the FixCapitalization() function. FixCapitalization() has a string parameter and updates the string by replacing lowercase

letters at the beginning of sentences with uppercase letters. FixCapitalization() DOES NOT output the string. Call FixCapitalization() in the

ExecuteMenu() function, and then output the edited 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!

(8) Implement the ReplaceExclamation() function. 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 the

ExecuteMenu() function, and then output the edited 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.

Question image 1Question image 2Question image 3Question image 4Question image 5