Programming Exercise 2-7
# Declare variables to hold miles driven, gallons
# of fuel used, and miles-per-gallon.
miles = 0.0
gallons = 0.0
mpg = 0.0
# Get the miles driven.
miles = float(input(“Enter the miles driven: “))
# Get the gallons of fuel used.
gallons = float(input(“Enter the gallons of fuel used: “))
# Calculate miles-per-gallon.
mpg = miles / gallons
# Print the result.
print (“You used”, format(mpg, ‘.2f’), “miles per gallon.”)
Start
Declare Real miles,
gallons, mpg
Display “Enter
the miles
driven.”
Input miles
Display “Enter
the gallons of
fuel used.”
A
A
Input gallons
Set mpg = miles /
gallons
Display “You
used”, mpg
“miles per
gallon.”
End