Question
For this assignment, the output is incorrect, e.g.: For Service 1: - is entered. For Service 2: Car Wash or Car wax or Oil change
For this assignment, the output is incorrect, e.g.:
For Service 1: "-" is entered.
For Service 2: Car Wash or Car wax or Oil change is entered.
The Output is incorrect(backward)
Service 2: Car wash, $7
Service 1: No service
Total: $7
The code:
#4.10 Program: Automobile service invoice (Python 3)
#Implementation of automativeService class
#START
class automativeService():
#Implementation of displayInvoice method
def displayInvoice(self):
#Display statements
print("Davy's auto shop services")
print("Oil change -- $35")
print("Tire rotation -- $19")
print("Car wash -- $7")
print("Car wax -- $12")
#Get the input
print()
service1 = input("Select first service: ")
service2 = input(" Select second service: ")
print()
#Declare the dictionary and initailize it
dic ={"Oil change":"35","Tire rotation":"19","Car wash":"7","Car wax":"12"}
#Declare the total and assign zero
total = 0
#Display statements
print()
print("Davy's auto shop invoice")
print()
#Iterate the dictionary values
for key,value in dic.items():
if(service1 == key):
print ("Service 1:",key+str(", $")+dic[key])
total = total + int(dic[key])
if(service2 == key):
print("Service 2:",key+str(", $")+dic[key])
total = total + int(dic[key])
#if the service1 value is - then it display No service
if(service1 == "-"):
print("Service 1:","No service")
#if the service2 value is - then it display No service
if(service2 == "-"):
print("Service 2:","No service")
print()
#Display the total
print("Total: $%.f" % total)
#Create an object for automativeService class
object1 = automativeService()
#call the method displayInvoice through while loop up to number of times
object1.displayInvoice()
#END
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started