Question

In: Computer Science

Can you write this program, but in python, I just wanna see what am I doing...

Can you write this program, but in python, I just wanna see what am I doing wrong. thank you

Instructions: 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.

User Request: Write a program that prints a statement for a customer.

Analysis: 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 <Enter> 9.7

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

Enter Y or N for car wash and press Y

************************************** * *

* Gas-N-Clean Service Station *

* March 2, 2004 *

* * * **************************************

Amount Gasoline purchases 9.7 Gallons

Price pre gallons $ 2.89

Total gasoline cost $ 28.03

Car wash cost $ 1.25

Total due $ 29.28

Thank you for stopping

Please come again

Remember to buckle up and drive safely

Solutions

Expert Solution

#Python program that prompts for number of gallons , gas type and Y or N for car wash then print the #total due for car.
#gas.py

def main():
    #gas type costs
    REGULAR=2.89
    PLUS=3.09
    SUPER=3.39

    carWashCost=0
    pricePerGallon=0

    gasOlineCost=0

    # number of gallons from keyboard
    numGallons=float(input('Enter number of gallons and press : '))

    #read gas type
    gasType=input('Enter gas type(R, P, S or N) and press : ')

    #read Y or N for car wash
    carWash=input('Enter Y or N for car wash and press : ')

    #check gasType and corresponding price per gallon
    if gasType=='R':
        pricePerGallon=REGULAR
    elif  gasType=='P':
        pricePerGallon=PLUS
    elif gasType == 'S':
        pricePerGallon = SUPER
    elif gasType == 'N':
        pricePerGallon = 0


    #check if number of gallons is 10 or more then set car wash cost 1.25
    #otherwise less than 10, set car wash cost 3.00
    if numGallons >=10:
        carWashCost=1.25
    else:
        carWashCost=3.00

    #calculate teh gasoline cost
    gasOlineCost=numGallons*pricePerGallon

    print('************************************** * *')
    print('* Gas-N-Clean Service Station *')
    print('* March 2, 2004 *')
    print('************************************** * *')

    #calculate total due by adding gasonline cost to car wash cost
    totaldue=gasOlineCost+carWashCost


    #print the valus on python console with two decimal values
    #{0} for first argument in format
    #{0:.2f} is for print value upto two decimal values  where f is for float values
    print('Amount Gasoline purchases {0} Gallons'.format(numGallons))
    print('Price pre gallons $ {0}'.format(pricePerGallon))
    print('Total gasoline cost $ {0:.2f}'.format(gasOlineCost))
    print('Car wash cost $ {0:.2f}'.format(carWashCost))
    print('Total due ${0:.2f}'.format(totaldue))
    print('Thank you for stopping')
    print('Please come again')
    print('Remember to buckle up and drive safely')
main()

Sample Output:

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 : N
************************************** * *
* Gas-N-Clean Service Station *
* March 2, 2004 *
************************************** * *
Amount Gasoline purchases 9.7 Gallons
Price pre gallons $ 2.89
Total gasoline cost $ 28.03
Car wash cost $ 3.00
Total due $31.03
Thank you for stopping
Please come again
Remember to buckle up and drive safely


Related Solutions

I am having a trouble with a python program. I am to create a program that...
I am having a trouble with a python program. I am to create a program that calculates the estimated hours and mintutes. Here is my code. #!/usr/bin/env python3 #Arrival Date/Time Estimator # # from datetime import datetime import locale mph = 0 miles = 0 def get_departure_time():     while True:         date_str = input("Estimated time of departure (HH:MM AM/PM): ")         try:             depart_time = datetime.strptime(date_str, "%H:%M %p")         except ValueError:             print("Invalid date format. Try again.")             continue        ...
I just need 3 and 5. I am not sure what I am doing wrong. I...
I just need 3 and 5. I am not sure what I am doing wrong. I get different numbers every time. Superior Markets, Inc., operates three stores in a large metropolitan area. A segmented absorption costing income statement for the company for the last quarter is given below: Superior Markets, Inc. Income Statement For the Quarter Ended September 30 Total North Store South Store East Store Sales $ 4,800,000 $ 960,000 $ 1,920,000 $ 1,920,000 Cost of goods sold 2,640,000...
What am i doing wrong. I want for the program to run through then when it...
What am i doing wrong. I want for the program to run through then when it gets to "do you want to play again?enter yes or no" if they choose yes I want it to run again if they choose no then end. def play(): print("Welcome to the Game of Life!") print("A. Banker") print("B. Carpenter") print("C. Farmer") user_input = input("What is your occupation? ").upper() if user_input == "A": money = 100 elif user_input == "B": money = 70 elif user_input...
Please include comments on what you are doing.   Using linked lists, write a Python program that...
Please include comments on what you are doing.   Using linked lists, write a Python program that performs the following tasks: store the records for each college found in the input file - colleges.csv - into a linked list. (File includes name and state data fields) allow the user to search the linked list for a college’s name; display a message indicating whether or not the college’s name was in the database allow the user to enter a state's name and...
I am doing the lab of chromatography of spinach. Can you briefly explain what "sources of...
I am doing the lab of chromatography of spinach. Can you briefly explain what "sources of error" in this experiment? Limitation of technique and improvment? There is no any information is given. Just need some explains
I am trying to make a program in Python that opens a file and tells you...
I am trying to make a program in Python that opens a file and tells you how many lines, vowels, consonants, and digits there are in the file. I got the print out of lines, digits, and consonants, but the if statement I made with the vowels list isn't recognizing them. How can I make the vowels go through the if statement with the list? Am I using the wrong operator? Here is my program #Assignment Ch7-1 #This program takes...
This is in Python I am getting an error when I run this program, also I...
This is in Python I am getting an error when I run this program, also I cannot get any output. Please help! #Input Section def main(): name=input("Please enter the customer's name:") age=int(input("Enter age of the customer: ")) number_of_traffic_violations=int(input("Enter the number of traffic violations: ")) if age <=15 and age >= 105: print('Invalid Entry') if number_of_traffic_violations <0: print('Invalid Entry') #Poccessing Section def Insurance(): if age < 25 and number_of_tickets >= 4 and riskCode == 1: insurancePrice = 480 elif age >=...
I just wanna ask a simple question, but i need some explanation about it. What is...
I just wanna ask a simple question, but i need some explanation about it. What is the Physical quantities (Probably Wavelength or something like that) that causes every people has their own unique sound? Not Frequency Right? Because if frequency, people can just adjust their sound to make their frequency same with other people sound.
Can you please write this in python and comment as well so I can understand what...
Can you please write this in python and comment as well so I can understand what yo are doing. Thank you. 1)Loop through list A, at each iteration, show the square root result of that element. Add proper text to your print function. A = [-4, 1, -16, 36, -49, 64, -128] 2)Create a counter variable, name it i and initialize it to 0. Using a for loop, count how many numbers are divisible by 3 in range of 1...
I am confused with Python I have to write a specification for an email address. In...
I am confused with Python I have to write a specification for an email address. In one string a valid email address and the other without a valid email address. Ex: print(text_match("My teacher’s email is [email protected]")) print(text_match("My teacher has no email address"))
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT