Question: C++ help Write a program that performs the following tasks (do as many as you can): 1 . Define the 4 following sentences as string

C++ help

Write a program that performs the following tasks (do as many as you can):

1. Define the 4 following sentences as string literals in your program

The rain in Spain falls mainly on the plains.

Suzy sells seashells by the seashore.

Can you keep the cat from clawing the couch? It's creating chaos.

Fred's friends fried Fritos for Friday's food.

2. Store the strings in either an array or vector your choice.

3. Process each of the strings as follows, one by one (i.e., dont let your program proceed to the next string until after performing all the procedures below on your current string and reporting the results).

4. First, simply print the string and report the number of characters in the string/sentence (i.e., the strings length).

5. Then, report the number of words in each sentence (not necessarily unique words, just the number of actual words in the string). This will require you to parse the string character by character, stopping each word after a space or a newline ( ) character. You should put the words into an array or (preferably) a vector.

6. Then, count the number of vowels, the number of consonants, and the number of punctuation or other characters in the string. This will require you to first create a map, 2D array, switch statement, etc. to tell you what category a particular character falls in (i.e., consonant, vowel, other).

7. Convert the text in each line/string to Title Case and print the result (first letter of each word is capitalized). Like this: My Dog Has Fleas

8. Convert the text in each line to Toggle Case (the first letter of each word is to be lowercase while the rest of the letters in each word are to be uppercase). Like this: mY dOG hAS fLEAS

9. Convert the text in each line to Sentence Case (capitalize the first letter of the first word in the entire string but lowercase all the remaining words). a. Optional (10 extra points): Convert the case for all words except for I, Suzy, et al, plus any other proper words you want to specify in a lookup table, as long as your sentence contains two or more of those words and are treated properly (e.g, never lower-casing them). b. Find the longest word in each sentence and report it.

10. After doing all the above, proceed to the next sentence in your list.

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!