192k views
3 votes
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, the output is:

1.57995 7.89975 63.198

Needs to be in Coral language

2 Answers

2 votes

Answer:

def driving_cost(driven_miles, miles_per_gallon, dollars_per_gallon):

gallon_used = driven_miles / miles_per_gallon

cost = gallon_used * dollars_per_gallon

return cost

miles_per_gallon = float(input(""))

dollars_per_gallon = float(input(""))

cost1 = driving_cost(10, miles_per_gallon, dollars_per_gallon)

cost2 = driving_cost(50, miles_per_gallon, dollars_per_gallon)

cost3 = driving_cost(400, miles_per_gallon, dollars_per_gallon)

print("%.2f" % cost1)

print("%.2f" % cost2)

print("%.2f" % cost3)

Step-by-step explanation:

User Brandon Zacharie
by
6.9k points
3 votes

Answer:


x^(2) \left[\begin{array}{ccc}1&2&3\\4&5&6\\7&8&9\end{array}\right] \int\limits^a_b {x} \, dx  \lim_(n \to \infty) a_n √(x) \sqrt[n]{x} \pi \alpha (x)/(y) x_(123) \beta

Step-by-step explanation:

User Eli Lansey
by
6.7k points