Assignment 7 — multi-input problem solving
Due time: Wednesday, September 9
Download
Program all_consuming.py
- Develop a program that estimates your annual consumption of a commodity based on how much you consume a normal weekday and a normal weekend day.
Assumptions
- The term week denotes 5 weekdays and 2 weekend days.
- Assume a year is exactly 52 weeks (yes, we know a real year is longer, but we will ignore that in this program).
- User supplied inputs are integers.
Requirements
- The program first prompts the user for the commodity consumed.
- The program then individually prompts the user for two integer inputs: first, the quantity consumed on a typical weekday, then the quantity consumed on a typical weekend day. These are to be requested using two separate prompts.
- The program uses the inputs to compute and report the estimate of the quantity consumed in a year.
- The quantity output should specify the commodity whose use is being reported.
Suggested agorithm
- Get input commodity of interest
- Get weekday consumption
- Get weekend day consumption
- Compute weekly consumption
- Compute yearly consumption
- Report yearly consumption
Three program runs
What is something you consume daily? paper napkins
How much consumed on a normal weekday: 6
How much consumed on a normal weekend day: 0
You consume 1560 paper napkins per year.
What is something you consume daily? pretzels
How much consumed on a normal weekday: 0
How much consumed on a normal weekend day: 1
You consume 104 pretzels per year.
What is something you consume daily? jelly beans
How much consumed on a normal weekday: 4
How much consumed on a normal weekend day: 12
You consume 2288 jelly beans per year.
© 2020 Jim Cohoon | Resources from previous semesters are available. |