Question: C++ PROGRAM Your task is to create the hated form letter. You will be reading in three lines of data for a potential customer, dividing
C++ PROGRAM
Your task is to create the hated form letter. You will be reading in three lines of data for a potential customer, dividing some of the strings into substrings, formatting some, and then embedding these strings / substrings where they belong into the body of the letter shown below.
Overview:
-
There are 3 lines of data to be entered per customer that will be read from the keyboard using getline()
statements. An example is:
Mrs Welch, Elizabeth 3307 3rd Ave. West Seattle, WA 981190241
-
You will then need to manipulate the strings so that various parts of them can be used to create a letter that looks like this:
Elizabeth Welch 1089 9th Ave. South Auburn, WA 98012
Dear Mrs. Welch
OutputLetterHeading()
Spring is coming to Seattle and we at Ice Cream of the Month know thatspring and summer are the best times for icy goodness. That is why we are offering all of our Washington friends a free 3-month trial membership in our club if you act NOW!
ELIZABETH, this is the first time our newest flavor, Peachy Keen, will be sold in the 98012 area. Just imagine the Weltz family enjoying a tasty sundaewith chocolate sauce and a cherry! The family will say, EW, you are ourhero!
We look forward to hearing from the WELCH FAMILY soon.
I. Alma Salsman Ice Cream of the Month, State of Washington
OutputSignature()
The underlined-and-colored words/letters are taken from the original 3 input strings. They are NOT expected to be underlined or colored in the output.
3. To make it simpler for you, the following can be assumed:
-
Each run of the program will only generate a single letter, which is output to the screen. (Feel free
to use a loop to create multiple letters in a run, but remember that this might combine getline()
with cin >>, so you will have to handle that.)
-
The user will always enter valid data in the 3 lines, including 2-character state abbreviations. All the
necessary "pieces" will be there (for example, Title LastName, FirstName for the first line and for the third line City, ST 999999999 That said, LastNames, FirstNames and Cities could contain multiple words. (For example, a city like Los Angeles.)
-
The text for the letter (except for the added strings) may be hardcoded in your program for simplicitys sake. I tried to avoid formatting it too much so your letter should be able to look pretty much exactly like the sample.
4. Be careful to notice where we use full state names, uppercase, and full or formatted Zip codes (for example). THESE VARIATIONS on the original strings MUST BE CREATED PROGRAMMATICALLY!
The Functions: THESE are required. You may include ADDITIONAL functions if that helps you avoid writing duplicate code. For example, how many times do you want to write the code that figures out the state name?
EnterUserData()You will need a function that gets three lines of data from the keyboard into three string reference parameters using getline(). If you do this correctly, all the function needs to have is the prompts and three getline() statements. (See Overview item 1) This is the ONLY input to the program (unless you want to do the optional loop from Overview 3a).
OutputLetterHeading()A second function receives the 3 input lines as value parameters, then outputs the letter heading (see sample). Note how you will need to manipulate the strings...they aren't EXACTLY like the input lines.
OutputLetterBody()Outputs all of the letter except the heading and the signature. You only need to send it two of the original lines (so don't send all three) as value parameters. You will do a LOT of manipulating of the strings.
Key to working with the state: You will be entering two-char state abbreviations. To simplify lookup ofstates (since sometimes you need to output the abbreviation and sometimes the full state), note that Ice Cream of the Month only does business in Washington (WA), Oregon (OR), and California (CA).
OutputSignature()See the sample for the lines that are output by this function. As with the body function, only two of the original input lines are used as value parameters.
TO HAND IN:
-
1) Your main.cpp source code.
-
2) Screen shots of the letters generated by the following two sets of input (since I'll assume you can do the
Welch input for your own debugging...)
Mrs Solo, Leia Organa 7603 Claremont Place Mount Vernon, WA 982737603
Mr Van Pelt, Linus 226 Peanuts Lane Petaluma, CA 949522524
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
