In: Computer Science
Write a program that will calculate and display the cost of a gasoline purchase based on the brand of gasoline, the octane rating and the amount purchased.
Your program should first display a menu prompting the user for the brand of gasoline. Next prompt the user for the amount of gasoline in liters.
Finally, your program should calculate and display the cost of the gasoline purchase using the formula below.
Notice that the units of measure for the amount of gasoline in the formula are in gallons (not liters). You will need to convert liters into gallons using this conversion factor: 1 liter = 0.264172 gallons
Sample Input and Output (output should match exactly, including decimal scale)
CPCC Gasoline Services
Enter the brand type: 2
Enter the octane rating: 90
Enter the amount of gasoline in liters: 68.04
The cost of the gasoline is $51.95
#printing initials
print('CPCCC Gasoline Services')
print('Discount')
print('Premium')
#taking inputs
brand=int(input("Enter the brand type: "))
rating=int(input("Enter the octane rating: "))
liters=float(input("Enter the amount of gasoline in liters: "))
#changing liters to gallons
gallons=float(liters*0.264172)
#calculating cost according to type of brand
if brand==1:
cost=float((2.49-(100-rating)*0.01)*gallons)
elif brand==2:
cost=float((2.99-(100-rating)*0.01)*gallons)
#rounding cost to 2 decimal places
cost=round(cost,2)
#printing cost
print("The cost of the gaasoline is $",cost)
OUTPUT: