Assignment 05

Prescription Recipes

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

1. Aspirin

2. Snake Oil

3. Mouthwash

4. Toothpaste

5. Quit

The menu is to be presented after each choice is made and the related information output; the menu is replaced by a sign off message only when the option to quit is chosen. Now you may want to take exception to this list of meds, but they go a lonnnngggg way in the Spuckler family. Your program does NOT have to worry about the number of units of the drug (number of pills, ozs of liquids, ml of pastes, et), it only has to output to the screen what the instructions say below.

Your main function will use a switch-case statement to handle the choices for this menu of options. Each option will be handled by one or more function calls and other code if necessary. So, you will have functions as follows:

  • A function that greets the user with a pleasant greeting (perhaps a reassuring message that they don't have to graduate from grade school to be a doctor).

  • A function that signs-off the program. Both this function and the greeting function have no parameters and return nothing.

  • A function that requests the user enter the age of the patient, and returns this value as an integer. This function should reject an input (age) that is unreasonable...like under 0 and over 120.

  • A function that request the user enter the number of toes the patient has, and returns this value as an integer. Reasonable limits on the input should be built into this function (0 -> 10 sounds reasonable).

  • Note: If you are really good, you can replace these last two functions (above) with one function that is used in two ways. Can you do it??

  • A function called computePossumFatAmount() ... no, really! that's what you're going to call it ... that returns an int that is the product of the two ints passed to it.

Specifications: Your program is to do the following and to do it using functions. Below, we will describe what the functions will do. You are required to use the functions described below, but you are welcome to include other functions as you deem necessary. This is to be a menu-driven program, which means that the program will present a menu for the user. That menu should look like this:

Due: Tuesday, March 1, 2016 at noon 100 points

Background: As you all know, Cletus grew up in less-than-desireable circumstances. Mostly he has been poor and uneducated. He's always trying to improve life for himself and his wife and 4000 kids. Learning how the pharmaceutical industry has the country in the grips of the "I gotta have a pill to be able to cope with anything anymore" craze, Cletus has plans to open his own pharmacy. "Cletus's Farmassy" will no doubt bring Mr. - ne, Dr. Spuckler! into a fortune that he can use to make himself and his family rich. Alas, Cletus hasn't yet graduated from 2nd grade, and so has trouble figerin' how to put them pesky drugs together. This program you are to write will help him.

  • This function computes the amount of rendered possum fat that is required for some recipes in Cletus's medicine chest. Unfortunately, Cletus doesn't know how to multiply, and your function will do it for him. An aspirin_recipe() function that returns nothing, but outputs

aspirin:

15 grams <ingredient #1>

2 grams <ingredient #3>

6 grams <ingredient #5>

  • A snakeoil() function that returns nothing, but it will first request the number of toes that the "patient" has and then it will output

computePossumFatAmount() function passing age and 4 to its parameters. And, the number 4 is a constant multiplying factor set by the International Toothpaste Possum Fat Commission for the production of toothpaste.

-------along with the same list of ingredients for aspirin -------

And so now you are wondering what all these "ingredients" are? Cletus could only find one distributor of pharmacological ingredients....his kids. They bring him reasonable mixers for his apothecary. Here are the current ingredients they supply him with:

  1. ingredient #1 is sugar

  2. ingredient #2 is Karo syrup

  3. ingredient #3 is baking soda

  4. ingredient #4 is rotgut vodka

  5. ingredient #5 is ground acorn hulls

  6. ingredient #6 is rendered possum fat

  7. ingredient #7 is used motor oil

When you submit: As usual, you will run the program when submitting. Enter the following values:

  1. option 1

  2. option 2 with number of toes -5

  3. option 2 with number of toes 5

  4. option 3 with age -10

  5. option 3 with age 140

  6. option 3 with age 56

  7. option 3 with age 5

  8. option 4 with age 18

  9. quit

And, as usual, if you have any trouble with this assignment, take two of Dr. Cletus's aspirins and rinse your mouth with Dr. Cletus's mouthwash.....and then ask your teacher for help and some snake oil.

snake oil:

2 tbls <ingredient #2>

5 tbls <ingredient #7>

2 liters <ingredient #4>

the number of tbls of <ingredient #6> as determined by a call to the computePossumFatAmount() function passing the number of toes and 6 to its parameters. The value 6 is a constant multiplying factor set by the International Snake Oil Possum Fat Commission for the production of snake oil.

  • A mouthwash() function that returns nothing, but it will also request the age of the patient. Then, it will output

mouthwash:

1 liter of <ingredient #2> if age less than 12; 2 liter of <ingredient #4> otherwise

5 tbls of <ingredient #7>

  • A toothpaste() function that will also get the age of the patient, and then will output

toothpaste:

the number of tbls of <ingredient #6> as determined by a call to the