Assignment 02

Due: Friday, Sept. 7, 2018 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 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 2 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. During the submission process, your program will be executed, so you will have to input information to answer your program's prompts. The inputs will be given below.

Background: Herschel Shmoikel Pinchas Yerucham Krustofski (a.k.a. Krusty-the-Klown) is going to hire you this semester to write some programs to make running his businesses (Krusty Korporation) more efficient. And his first concern is the deliterious health effects his fast food has on the populace. It is currently estimated that 50% of all residents of Springfield die from congestive heart disease due to dining on Krusty Krap at Krusty Burger. So, Krusty desires that you write a program that will estimate the probability someone will have a heart attack based on what they eat at his fine eating establishment. Furthermore, it will compute the number of miles the customer needs to run in order mitigate this effect. The customers will be able to run this program after they order.

Specifications: Your program will prompt the customer for the number of burgers, the number of (orders of) fries, and the number of milkshakes they ordered and the length the queue. These values will be used in a formula developed through rigorous scientific investigative methods by Prof. Frink. It is:

chance of heart attack = (number of burgers + number of fries) * (number of milkshakes / (length of queue + 1)) + <<AQF>>,

where chance of heart attact is a percentage chance

length of queue is the number of other customers in front of the customer in their queue when they arrived

AQF is the "air quality factor", and is currently 5.6. It changes weekly. This is a value that gauges the amount of grease in the air in the restaurant. The "<< >>" signifies that it is added only if the customer buys at least one each of burgers, fries, and milkshakes.

miles = chance of heart attack * KBMF,

where KBMF (Krusty Burger Mitigation Factor) is the known value 19.7

So, you will begin your program by greeting the user. Then, you need to prompt for and read in the user input for the calculation(s). Once you have determined the chance of heart attack and the number of miles to run off these effects, output the information appropriately. You will output the chance of a heart attack as a percentage. Output the mileage as the (whole) number of whole marathons required (take a marathon to be exactly 26 miles) and the leftover miles. Do it in a "user friendly" output. This excludes simple output like:

7.2 5 11.84

Notice that there is no label on the numbers, etc. Your output should look NICE like:

For inputs: 3 burgers 1 fries 2 milkshakes 4 in queue chance of heart attack is 7.2% You need to run 5 marathons plus 11.84 miles to save your life!

.... or something like this. You get the idea. (The preceding example assumes that you prompted for the info and the customer actually entered 3 burgers, 1 fries, and 2 milkshakes. This is just to show the output. By the way, this is called "echoing inputs".)

Note: You are NOT to use the if or if-else statements in this programming assignment. There will be one point where you will want to use an if-statement, but if you listened carefully to our lecture, you will figure out a way to avoid it.

Remember: When writing your code, be sure to:

  • Declare your variables with the APPROPRIATE type.

  • Use meaningful variable and constant names. Don't just copy any variable/constant names I might have used in this assignment. Use your head and creativity.

  • Use proper spacing for indentations.

  • Use constant 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.

When you submit this, and all subsequent programs for this class, cssubmit will compile and run (assuming it compiles) your program during the submission process. Thus, when you submit, you will have to enter inputs as a user of the program. Now, in order to make the output uniform for the grader and to keep her sane, ALL OF YOU will enter the same information. For this assignment, it is:

  • 5 burgers

  • 2 fries

  • 3 milkshakes

  • 3 in queue

As always, if you have questions about this assignment, just ask your cs 1570 instructor. DO NOT ask your lab instructor as it is not his/her job to answer such questions.