Revision Date: January 8, 2017
Stepwise refinement is the process of steadily building up a solution by solving one small piece of the problem at a time. For this class, we've organized each piece of the problem into levels, where each level builds upon the last. If you need assistance with a particular level, you must first demonstrate that you've successfully completed the previous level.
Then you should calculate the following answers:
1028.5 | Yearly cost of gasoline without modification |
970.35 | Yearly cost of gasoline with modification |
0.9446 | Number of years for pay off (decimal) |
0 years and 344 days | Number of years and days for pay off (integers) |
If you don't have a calculator on hand, you can use the python3 interpreter as a simple calculator.
Example:
>>> 10 / 2 5.0 >>> 5.0 * 12 60.0 >>> 60 / 8 7.5
*
, /
, +
, or -
).
So, for example, if you needed to calculate the average sales over three days, given SalesDay1, SalesDay2, and SalesDay3, you would write something like the following down on your sheet of paper:
For this level, You should not have multiple operations such as:
Average = (SalesDay1 + SalesDay2 + SalesDay3) / 3.0
print("Miles per year given:", milesPerYear)
cp level2.py level3.py
).
In this file, add new code to
perform each step of the calculation for finding the yearly cost of gasoline
without the modification. Use the same step by step approach you used in
Level 1. Print out each intermediate value with an appropriate description. Once you have calculated
the final value and assigned it to an appropriately name variable, print out
the final value with an appropriate description.
lusth@cs.ua.edu