Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to submit: Upload your entire project (code, copies of output files, comments, etc.) in a zip file to the eLearning site. The project must

How to submit: Upload your entire project (code, copies of output files, comments, etc.) in a zip file to the eLearning site. The project must compile on either Codeblocks or MS Visual Studio 2015 (or later).

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

1. Define several string literals in your program, say up to at least 4 of the following sentences (or alternatively, you can read them in from a file that you include with your submission):

The rain in Spain falls mainly on the plains. How much wood would a woodchuck chuck if a woodchuck could chuck wood? Suzy sells seashells by the seashore. Becky's beagle barked and bayed, becoming bothersome for Billy. Can you keep the cat from clawing the couch? It's creating chaos. Dan's dog dove deep in the dam, drinking dirty water as he dove. Fred's friends fried Fritos for Friday's food. Greedy goats gobbled up gooseberries, getting good at grabbing the goodies. Rudolph the red-nosed reindeer rose rapidly into the air. Seven sisters slept soundly on the sand.

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.

11. For extra fun, try this sentence (including all the punctuation characters as shown):

It is just a meaningless, repetitive phrase that a linguist, Professor Henry Higgins (in the movie My Fair Lady) used as a mnemonic device to help the learner (Liza) learn the correct way to pronounce the diphthong ai, as in aim and main, rather than the Cockney pronunciation of it, which sounds like the i in Rhine and spine.

Annotations for the code:

1. The main function can be at either the beginning or the end of the program. I dont care which. (There are pros and cons for each decision.)

2. Separate the output for each sentence from the next sentence, using one or more blank lines or something like the line() function weve seen several times in class.

3. Add comments at the top of your main.cpp file to include your name, the name of the program, and notes on how your design works when executed. Point out any special features or techniques you added using a comment saying // Special Features.

4. Comment your code effectively, as we discussed in class. Use descriptive variable names everywhere so that the code becomes as self-documenting as possible. Use additional commentary to improve readability and comprehensibility by other people.

5. You absolutely MUST use consistent indentation and coding styles throughout the program. Failure to do so will result in a loss of five points.

6. If the program does not work at all or even in part, or works incorrectly, 10 points will be deducted.

7. Leave Your Debugging code in ur program! (But turn it off or to comment it out before submitting the homework.)

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

Recommended Textbook for

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions

Question

=+CASE 2. Sr. By the second part of (7.30), A(r,s) =qA(2r-1,2s-1)0.

Answered: 1 week ago

Question

What is the relationship between humans and nature?

Answered: 1 week ago