Question: Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles,
Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles.
Ex: If the input is:
20.0 3.1599
Then the output is:
1.579950 7.899750 63.198000
Note: To solve the problem, calculate first the gas cost for driving a mile. Then use this result to compute the gas cost for 10 miles, 50 miles, and 400 miles.
Note: Real per-mile cost would also include maintenance and depreciation.
Note: Output appears on one line
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
