Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

What is the cycle-of-violence hypothesis?

Answered: 1 week ago

Question

1. Identify three approaches to culture.

Answered: 1 week ago

Question

3. Identify and describe nine cultural value orientations.

Answered: 1 week ago

Question

4. Describe how cultural values influence communication.

Answered: 1 week ago