Thread: hello I need help with this python homework.

Results 1 to 2 of 2
  1. #1 hello I need help with this python homework. 
    Donator

    H1N1's Avatar
    Join Date
    Oct 2009
    Posts
    793
    Thanks given
    25
    Thanks received
    61
    Rep Power
    153
    Ex:

    Davy's auto shop services
    Oil change -- $35
    Tire rotation -- $19
    Car wash -- $7
    Car wax -- $12



    (2) Prompt the user for two services from the menu. (2 pts)

    Ex:

    Select first service: Oil change

    Select second service: Car wax



    (3) Output an invoice for the services selected. Output the cost for each service and the total cost. (3 pts)


    Davy's auto shop invoice

    Service 1: Oil change, $35
    Service 2: Car wax, $12

    Total: $47



    (4) Extend the program to allow the user to enter a dash (-), which indicates no service. (3 pts)

    Ex:

    Select first service: Tire rotation

    Select second service: -


    Davy's auto shop invoice

    Service 1: Tire rotation, $19
    Service 2: No service

    Total: $19

    This is the code I have

    Code:
    def automobile():
     
     
    # Display the menu
     
     print("Davy's auto shop services")
     
     print("Oil change -- $35")
     
     print("Tire rotation -- $19")
     
     print("Car wash -- $7")
     
     print("Car wax -- $12")
     
    # Declare and initialize the Variables
     
    changeOil = 35;
     
    rotationTire = 19;
     
    washCar = 7;
     
    waxCar = 12;
     
    t = 0;
     
    service1 = 0;
     
    service2 = 0;
     
    # Call to the function
     
    automobile()
     
    # Prompt the user to enter the service.
     
    first_ser = input("Select first service:")
     
    # Check whether the service is oil change or not
     
    if (first_ser == "Oil change"):
     
    # Add the cost of oil Change.
     
      t = t + changeOil;
     
      service1 = changeOil;
     
    # Check whether the service is Tire rotation or not
     
    elif (first_ser == "Tire rotation"):
     
    # Add the cost of Tire rotation.
     
      t = t + rotationTire;
     
    # Assigning value to variable.
     
      service1 = rotationTire;
     
    # Check whether the service is Car wash or not
     
    elif (first_ser == "Car wash"):
     
    # Add the cost of Car wash.
     
      t = t + washCar;
     
    # Assigning value to variable.
     
      service1 = washCar;
     
    # Check whether the service is Car wax or not
     
    elif (first_ser == "Car wax"):
     
    # Add the cost of Car wax.
     
      t = t + waxCar;
     
    # Assigning value to variable.
     
      service1 = waxCar;
     
    # Check whether the service is - or not
     
    elif (first_ser == "-"):
     
      first_ser = "No service";
     
    # Add the cost of no service.
     
      t = t + 0;
     
    # Prompt the user to enter the service.
     
    secondService = input("Select second service:")
     
    # Check whether the service is oil change or not
     
    if (secondService == "Oil change"):
     
    # Add the cost of Car wax.
     
      t = t + changeOil;
     
    # Assigning value to variable.
     
      service2 = changeOil;
     
    # Check whether the service is Tire rotation or not
     
    elif (secondService == "Tire rotation"):
     
    # Add the cost of Tire rotation.
     
      t = t + rotationTire;
     
    # Assigning value to variable.
     
      service2 = rotationTire;
     
    # Check whether the service is Car wash or not
     
    elif (secondService == "Car wash"):
     
    # Add the cost of Car wash.
     
      t = t + washCar;
     
    # Assigning value to variable.
     
      service2 = washCar;
     
    # Check whether the service is Car wax or not
     
    elif (secondService == "Car wax"):
     
    # Add the cost of Car wax.
     
      t = t + waxCar;
     
    # Assigning value to variable.
     
      service2 = waxCar;
     
    # Check whether the service is - or not
     
    elif (secondService == "-"):
     
      secondService = "No service";
     
      service2 = 0;
     
      t = t + 0;
     
    # Display the results.
     
    print()
     
    print("Davy's auto shop invoice")
     
    print()
     
    if (first_ser == "No service") and (secondService == "No service"):
     
        print("Service 1:" + first_ser)
     
        print("Service 2:" + secondService)
     
        print()
     
     
     
    elif (secondService == "No service"):
     
      print("Service 1:" + first_ser + ",$" + str(service1))
     
      print("Service 2:" + secondService)
     
      print()
     
    elif (first_ser == "No service"):
     
      print("Service 1:" + first_ser)
     
      print("Service 2:" + secondService + ",$" + str(service2))
     
      print()
     
    else:
     
      print("Service 1:" + first_ser + ",$" + str(service1))
     
      print("Service 2:" + secondService + ",$" + str(service2))
     
      print()
     
    print("Total: $" + str(t))
    Attached image
    Reply With Quote  
     

  2. #2  
    Banned
    Join Date
    Jan 2018
    Posts
    8
    Thanks given
    0
    Thanks received
    2
    Rep Power
    0
    Worked fine for me

    Attached image
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. need help with this
    By mjas in forum Help
    Replies: 1
    Last Post: 05-19-2009, 09:56 PM
  2. I need help with this error
    By $anta2 in forum Help
    Replies: 6
    Last Post: 03-27-2009, 03:02 PM
  3. Need Help With This!!
    By Damien in forum Help
    Replies: 1
    Last Post: 03-04-2009, 09:56 AM
  4. Need help with this command
    By jat1802 in forum Help
    Replies: 7
    Last Post: 02-21-2009, 03:08 AM
  5. need help with this
    By Gluon in forum Configuration
    Replies: 6
    Last Post: 01-05-2009, 08:43 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •