Ask Question

The Gas-N-Clean Service Station sells gasoline and has a car wash. Fees for the car wash are $1.25 with a gasoline purchase of $10.00 or more and $3.00 otherwise. Three kinds of gasoline are available: regular at $2.89, plus at $3.09, and super at $3.39 per gallon.

Write a program that prints a statement for a customer.

Input consists of number of gallons purchased (R, P, S, or N for no purchase), and car wash desired (Y or N). Gasoline price should be program defined constant. Sample output for these data is

Enter number of gallons and press 9.7

Enter gas type (R, P, S, or N) and press R

Enter Y or N for car wash and press Y

+5
Answers (1)
  1. 25 April, 18:09
    0
    d = {"R":2.89,"P":3.09, "S":3.39, "N":0}

    noofgallons = input ("Enter number of Gallons:")

    gastype = input ("Enter Gas type/; R, P, S, N")

    cwr = input ("Is Car Was Requieed")

    if (gastype = = "R"):

    gal = = nooffgallons * d['R']

    if (cwr=="y" and gal<10):

    gal+=3.00;

    elif (cwr=="y" and gal>=10):

    gal+=1.25

    elif (cwr=="n"):

    gal=gal

    elif (gastype==P):

    gal= = nooffgallons * d['P']

    if (cwr="y" and gal<10):

    gal+=3.00;

    elif (cwr=="y"and gal>=10):

    gal+=1.25

    elif (cwr=="n"):

    gal=gal

    elif (gastype = =S):

    gal=noofgallons * d['S']

    if (cwr="y" and gal<10):

    gal+=3.00;

    elif (cwr=="y"and gal>=10):

    gal+=1.25

    elif (cwr=="n"):

    gal=gal

    print ("tptal cost paid" + gal)

    The above program uses a dictionary for storing gasoline types and their cost, and dictionary is always constant, and hence its fulfilled the requirement of keeping it constant. And car wash is treated accordingly. And if elif else ladder has been used to calculate the total number of gallons.

    Rest part is self explanatory.

    Explanation:

    The code is self explanatory.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “The Gas-N-Clean Service Station sells gasoline and has a car wash. Fees for the car wash are $1.25 with a gasoline purchase of $10.00 or ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers