| CPSC 115L: Introduction to Computing | Spring 2010 |
You should first begin with your I/O specification and algorithm for this problem. Then implement the function print_cost and write a code segment to invoke it in a Python script named fuel_cost.py. Run your script with five test cases, and save the snapshots of your test runs in a text file named fuel_cost.out. Put a file header at the top of each file.Enter the distance traveled for the 1st trip (in miles): 204 Enter the cost of a gallon of gas for the 1st trip (in dollars): 2.954 Enter the EPA mileage rating for the 1st trip (in MPG): 32 Your total cost is 18.83175 dollars. Enter the distance traveled for the 2nd trip (in miles): 102.5 Enter the cost of a gallon of gas for the 2nd trip (in dollars): 2.562 Enter the EPA mileage rating for the 2nd trip (in MPG): 25 Your total cost is 10.5042 dollars. Enter the distance traveled for the 3rd trip (in miles): 121 Enter the cost of a gallon of gas for the 3rd trip (in dollars): 2.789 Enter the EPA mileage rating for the 3rd trip (in MPG): 25 Your total cost is 13.49876 dollars.
As before, you should first begin with your I/O specification and algorithm. Then implement the function print_next_value and write a code segment to invoke it in a Python script named future_values.py. Run your script with five test cases, and save the snapshots of your test runs in a text file named future_values.out. Put a file header at the top of each file.Enter the initial value of an investment: 1000 Enter an annual interest rate: 0.025 After one year, your investment is worth 1025.0 dollars. After one year, your investment is worth 1050.625 dollars. After one year, your investment is worth 1076.890625 dollars.
|
|
CPSC 115L home page |
|
|