Question: You are to write a program that will calculate and print to the screen the miles per gallon your car gets, the cost of fuel

You are to write a program that will calculate and print to the screen the miles per gallon your car gets, the cost of fuel per mile and the annual cost of fuel for that car.
Your program must ask the user to enter the following information, and save the values entered into variables (use the names below):
beginningOdometerReading. ## save as an int
endingOdometerReading. ## save as an int
gallonsToFillTank ## save as a float
costPerGallonOf Gas ## save as a float
numberMilesDrivenPerYear ## save as an int
Most cars calculate the average miles per gallon for you. Assume you have an old car that does not. You have to calculate that yourself. So you fill up the tank, record the odometer reading, drive around, fill up the tank, record the odometer reading and the number of gallons of fuel you had to put into the tank to fill it. You calculate the miles per gallon by subtracting the endingOdometerReading from the beginningOdometerReading and then dividing by gallonsToFillTank
Assume that the cost of fuel remains the same all year.
To format a number as currency to two decimal points the command is (assuming that cost is the value, a variable name or an actual value you want formatted and printed):
print('${:,.2f}'.format(cost))
Here is a sample input/output:
Please enter the beginning odometer reading:
10000
Please enter the ending odometer reading:
10500
Please enter the number of gallons to fill the tank:
10
Please enter the cost per gallon of fuel:
3.00
Please enter the number of miles driven per year:
15000
Average Miles Per Gallon: 50.00
Fuel Cost Per Mile: $0.06
Annual Cost of Fuel: $900.00
Remember how to get input from the user:
Getting an int:
beginning_odometer_reading= int(input("Please enter the beginning odometer reading:))
Getting a float:
cost_per_gallon_of_fuel = float(input("Please enter the cost of a gallon of fuel:))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!