Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

**IMPORTANT!!: C++ only Note you must use the string operators and CHRACTER functions we discussed in class (Chapter 14 supplement) to solve this problem (examples:

**IMPORTANT!!: C++ only

Note you must use the string operators and CHRACTER functions we discussed in class

(Chapter 14 supplement) to solve this problem (examples: the subscript operator and the isupper function).

Do not use the standard template library functions in cases where you can solve the problem based

on what we learned in lecture

the point of the program is to utilize the material we learned in class. Only

use the functions like isalpha, tolower, and so on

Write a program that manipulates a string entered by the user.

1. The program should start by asking the user to enter a word, a sentence, or a string of numbers. Store whatever

the user enters into a C++ string (note: main will have only ONE string)

2. The program should then display the following menu (you must use Q for quit):

USE THIS MENU TO MANIPULATE YOUR STRING

----------------------------------------

1) Inverse String

2) Reverse String

3) To Uppercase

4) Count Number Words

5) Count Consonants

6) Enter a Different String

7) Print the String

0) Quit

?

If the user selects 1:

Make a function to inverse the upper and lower case letters of the string. If the string

contains numeric characters or special characters do not change them.

NOTE:

This option should actually

change the string

to its inverse.

Note this option does not display the changed string. If a user wanted to

inverse the string and then display the strings inverse they would select option 1 and then they would

select option 7.

Example:

If the string is:

My name is John and I am 20 years old.

The inverse would be:

mY NAME IS jOHN AND i AM 20 YEARS OLD.

?

If the user selects 2:

Make a function to reverse the order of the characters in the string.

NOTE:

This

option should actually

change the string

to its reverse. Note this option does not display the changed string. If

a user wanted to reverse the string and then display the strings reverse they would select option 2 and then they

would select option 7.

Example:

If the string is:

2015

The inverse would be:

5102

?

If the user selects 3

: Make a function to convert all of the characters in the string to uppercase. If the String

contains numeric characters or special characters do not change them.

NOTE:

This option should actually

change the string

to all uppercase letters. Note this option does not display the changed string. If a user

wanted to change the string to uppercase and then display the new string (in all uppercase) they would select

option 3 and then they would select option 7.

?

If the user selects 4

: Call a function named

countWords

that counts the number of words in the current

string and returns how many words are in the string. This option (not the function) actually should print

something.

Examples:

The string 2015 has one word

The string Hello World has two words

?

If the user selects 5:

Call a function named

countConsonants

that counts the number of consonants in the

current string and returns how many consonants the string contains. So this option (not the function) does print

something. Consonants are letters that arent vowels (anything EXCEPT a, e, i, o, u).

Example:

If the string is: Hello

The number of consonants is: 3

So display: The number of consonants in the string is 3.

?

If the user selects 6:

Let the user enter another string for processing. (This should just change the string

stored in the original string variable you created at the beginning of the program ... no function required)

?

If the user selects 7:

Print the String

o

So if the original string was Hello and the user processed the string with option 3 followed by

option 2, followed by option 7, the string would print out as OLLEH (This is hello first converted

to uppercase and then reversed ... no function required).

?

If the user selects 0:

Quit the program

?

Allow the user to continue processing strings (using the menu) until they select Q or q to quit

?

If the user makes an invalid menu selection, print an error message to the screen

Your program must include and use the following functions:

1.

inverse:

A function that takes a string and makes all lowercase characters uppercase and all uppercase,

lowercase. Returns the string

2.

reverse:

A function that takes a string and returns a string in reverse order.

3.

toUpper:

A function that takes a string and makes all lowercase characters into uppercase. Returns a string

4.

countWords

: A function that takes a string as an argument and counts the number of words in it (this function

should return an

int

which is the number of words in the string)

5.

countConsonants

: A function that takes a string as an argument and counts the number of consonants in it

(this function should return an

int

which is the number of consonants in the string)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data In Just 7 Chapters

Authors: Prof Marcus Vinicius Pinto

1st Edition

B09NZ7ZX72, 979-8787954036

More Books

Students also viewed these Databases questions