Welcome to Clayton's Cafeteria! Today we are featuring:
Because of previous trouble with the Federal Cafeteria Commission (FCC), we have been required to post information about the caloric and fat content of our foods:
| Food | Calories | Fat (g) |
| Jelly Donuts | 450 | 18 |
| Ice Cream | 350 | 20 |
| Cherry Pie | 500 | 15 |
Write a program that will ask which food they want from the menu and then report how much it costs and how much calories and fat there is. Output from such a program may look something like this:
Welcome to Clayton's Cafeteria!
1) Jelly Donuts $1.50
2) Ice Cream $2.20
3) Cherry Pie $3.141592
And what is your pleasure today? 2
Your order costs $2.2, has 350 calories, and 20 grams of fat.
Take your assignment from Part I and use a loop to make sure they only enter valid menu choices (HINT: do...while loops work well for this). The output for this should look exactly the same as Part I, except that the program should keep asking while the user enters bad choices. For example, if the user messes up three times, it would like this:
Welcome to Clayton's Cafeteria!
1) Jelly Donuts $1.50
2) Ice Cream $2.20
3) Cherry Pie $3.141592
And what is your pleasure today? 9
And what is your pleasure today? 0
And what is your pleasure today? -4
And what is your pleasure today? 2
Your order costs $2.2, has 350 calories, and 20 grams of fat.
Take your assignment from Part II and use a loop to let the user select as many items as they want (one at a time) until they are done ordering. Then tell them how much weight they can expect to gain, w, using the following formula:
w = 4.2c + 75f
where c is the number of calories and f is the grams of fat they consumed. w is returned in grams. If you want to convert this to pounds, multiply w by 0.0022046. If you want to convert this to kilograms, multiply w by 0.001. You can choose whether you want to display the final answer in kilograms or pounds, but you are required to choose 1 of them and display the amount they can expect to gain. After all that, your program's output may look something like this:
Welcome to Clayton's Cafeteria!
1) Jelly Donuts $1.50
2) Ice Cream $2.20
3) Cherry Pie $3.141592
4) Exit - Done Eating
And what is your pleasure today? 1
Your order costs $1.5, has 450 calories, and 18 grams of fat.
And what is your pleasure today? 2
Your order costs $2.2, has 350 calories, and 20 grams of fat.
And what is your pleasure today? 3
Your order costs $3.14159, has 500 calories, and 15 grams of fat.
And what is your pleasure today? 4
You can expect to gain 9.435 kg.
Obviously, the output will vary depending on what the exact order is. This example uses kilograms. If you want, you can use pounds instead. Also, don't feel obligated to keep track of the total cost. I prefer you keep track of their projected weight gain.
Part I is worth 8 points. Part II is worth 10 points (Part I + 2 more points). Part III is worth 12 points (Part II + 2 points extra credit). The lab is out of 10 points. When you're done, submit your lab03.cpp file on Blackboard. I will be grading your program on the following criteria:
![[Dilbert]](dilbert.gif)