Assignment 04

Due: Thursday, Sept. 23, 2019, at noon, 100 points

For this assignment, you will submit a single C++ compilable file containing a program written in C++. Remember, to submit a file for this course electronically, from the directory in which the file resides 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! The submit system will deliver every .cpp file in the current directory to me. 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: Dr. Nick, noticing that there are no vending machines in his lobby, decides to outsource the aquisition of said machinery. That's where you come into the picture. He wants you to write a program that will emulate the operation of said machine.

Specifications: Your program is to present the user with a main menu that should appear as follows with these choices:

MAIN MENU 1.) eyeballs $3.35 2.) spleen $2.75 3.) liver $14.58 4.) appendix $0.50 5.) brains $7.85 6.) ear lobes $13.45 (these are the good ones) 7.) Quit

So, the idea here is that you can vend your own transplant for Dr. Nick to install. It's a radical new idea in medicine. Saves money, ya know. (For your program, you don't have to have hyperlinks to pictures or anything like that.)

Details:

    • You are to use the switch-case statement for your initial " menu" structure. After the main "menu", you can write prompts any way you choose (as a menu or individual prompts).

    • The 4th and 5th buttons on the machine are broken. Here's how they are to work: if the user chooses brains, they also get earlobes. If they choose appendix, they get brains and earlobes also. Nice. They should be billed only for the last item.

    • After the user chooses an option, he/she/it is presented with the cost and a prompt for payment. Your program will then calculate the change from that payment, or issue an error message and reprompt if the amount tendered is insufficient.

    • Your program will also tell the vendee (that's the user) what the item weighs. This will indicate the minimum size pan the user should have on hand when that "thing" comes sllllidding out of the vending machine. There are a set of standard pans available: 1 lb., 2 lb., 5 lb. and 10 lb. pans. Your program is to tell the user which of these to have ready.

    • Note: brains weigh 0.4 lbs; spleens weigh 5.6 lbs; livers weigh 3 lbs; an appendix weighs 1.2 lbs; eyeballs are 2.3 lbs; and ear lobes are 10 lbs.

    • After all information is presented to the user, the main menu is to be presented again. Quit will terminate the program.

Remember: When writing your code, be sure to:

    • Use meaningful variable names.

    • Use proper spacing for indentations.

    • Use constant variable declarations where appropriate.

    • Include the comment block at the head of your file.

    • Comment code that needs it.

    • Be literate in your welcoming/signing-off messages and prompts and output.

    • Make the output pretty and user-friendly.

Note: Don't underestimate the time that it will take to write this program!

When you submit the submit script will compile and execute your program in the process. This means that you will be the "user" of the program for that few minutes. Now, in order that the grader isn't driven crazy by a multitude of inputs/outputs, you will ALL input the same values so that he has uniform output to grade. They are:

    • option 9 (uh, bogus input should beget a error message)

    • option 2

    • $5.00

    • option 4

    • $10, then $15

    • quit

1 Note: No animals were harmed in the preparation of this web page. We made fun of a few internal organs, only their feelings were hurt. We promise not to do it again.

As always, if you have questions, don't hesitate to ask your instructor or the LEAD tutors.