Assignment 05

For each of the above options 1 through 4, the user is prompted for information, and that will be used in a related computation. These are as follows:

  1. When option #1 is chosen, user is prompted for the number of pounds of food per day that is prepared for them but not actually eaten (see picture at right). To accomplish this, you will use a function that has no parameters and returns a float. It will output a prompt and read in a valid value (not negative and less than 100 lbs....certainly!).

  2. Option #2 will prompt the user for whether or not they use public transit (of any kind), and if so, how many miles used per day. Again, you are to use a function to do this. If public transit is not used, the function will return 0, and if it is, then it will return the number of daily miles traveled (an integer). The number of miles traveled should be at least 1 and no more than 250 miles.

  3. Choosing the third option will once again be handled by a function. It will trigger a prompt asking the user (y/n) if they are Mr. Burns. In the case of an affirmative response, the value (an integer) of the Burns industrial destruction coefficient will be returned - he's a very bad man! Currently, that value stands at 570. If not, then the user is asked if they are related to Burns, and if so, half the Burns constant is returned. If not, then the user is prompted for their age (yrs). In this case, the function will return their age.

  4. Option #4 can NOT be chosen unless option #1 has already been chosen. In the case option #1 hasn't already been chosen, the code should indicate so. If option #1 is already chosen, then a function will handle the following operation. This function will need to be passed the value that was returned by option #1, the poundage of food waste. The function will prompt the user for the (whole) number of whole pigs their father ate that week (see picture to the right). It then will compute and return a value determined by this formula:

    1. ††ret. val = waste * n2 + 3 * n + 5, where waste is the value passed into the function and n is the number of pigs eaten, and ret. val is thus a float-type.

  5. The computation of the GUILT value is allowed only after all previous options have been completed (in whatever order desired). Before the final computation, each value returned by options 1 and 2 need to be modified by multiplying by a certain constant and added to another constant. For wasted food, these values are 1.5 and 6, respectively; for transit usage, they are -2 and 1, respectively. These modifications are to be performed with a single function used twice, once for each value. Thus, the modification function will have three parameters: the value to be modified, the multiplier, and the offset. It will return the modified value. GUILT is then the sum of the (modified or not) values generated by the 4 options.

Finally, your program is to use a function to output the final GUILT value in an obsequiously1 friendly manner. After this, the program should terminate.

Notes:

  • Your code should be written so that once an option is completed, that option cannot be chosen again.

  • You will write two functions to implement a greeting to the user and a sign-off for the program. They will do nothing more than output appropriate messages.

  • Your code should range check inputs. We've given you some values for checking above, but others we have not. YOU come up with reasonable ranges (keeping in mind that Homer once ate 3 whole pigs in one episode!)

When you submit:

  • choose option 2 and answer affirmatively and enter 50 (miles)

  • choose option 4

  • choose option 1 and enter 38

  • choose option 5

  • choose option 3 and answer no and then yes

  • choose option 4 and enter 2 (pigs) - yes, that means you are either Bart or Maggie - what a drag

  • choose option 2

  • choose option 5

GUILT stands for Guide to Useless and Illogical Labeling of Tpolluters (the 'T' is silent ... oh that English, how convenient)

1Look it up...you have a dictionary don't you?

††This formula has no basis in fact. After all, Lisa is only in 2nd grade.....what can you expect?

5. Compute GUILT value

Carbon Footprint Survey

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

1. Wasteful (food) Consumption

2. Public Transit Usage

3. Industrial Complicity

4. Farm-related Methane Production

and Lisa can fund more tree-huggers.Specifications: Your program is going to have a menu. The menu should look like this:

Due: Thursday, Oct. 6, 2016 at noon 100 pts

For this assignment, you will submit a single C++ compilable file containing a program written in C++. Remember, to electronically submit a file to for this course, first change to the directory in which the file resides and then type in, at the UNIX prompt, the command:

cssubmit 1570 section_letter assignment_number

Be sure that only the file you want to submit is in that directory - make a directory for every assignment! Remember that the submit system will deliver every .cpp file in the current directory to me, so you should only have the file for hw 5 in that directory. Name your file a meaningful name and give it a .cpp extension since you will be compiling it. Also, make sure that you compile and run your program using the GNU (g++) compiler before submitting to make sure that it will work for the submit script.

Background: As we all know, most of the ills of the world are caused by carbon pollution, and Lisa is on a mission to educate the residents of Springfield. Her goal is to "spread the good word" and let her fellow Springfieldianerss how terrible the situation really is. She needs a computer program that will do the calculations for her. This is where you and your cs1570 programming expertise comes in. The program is to use information representing the daily habits of any particular individual to compute their "carbon footprint" so that Lisa can shame them into submission and compliance. The hope is that they will donate more money to the cause