Write a program to calculate the total price for car wash services. A base car was is $10. A dictionary with each additional service and the corresponding cost has been provided. Two additional services can be selected. A '-' signifies an additional service was not selected. Output all selected services along with the corresponding costs and then the total price for all car wash services.Ex: If the input is:Tire shineWaxthe output is:ZyCar WashBase car wash -- $10Tire shine -- $2Wax -- $3----Total price: $15Ex: If the input is:Rain repellent-the output is:ZyCar WashBase car wash -- $10Rain repellent -- $2----Total price: $12services = { 'Air freshener' : 1 , 'Rain repellent': 2, 'Tire shine' : 2, 'Wax' : 3, 'Vacuum' : 5 }base_wash = 10total = 0service_choice1 = input()service_choice2 = input()''' Type your code here '''

Answer :

Answer:

Replace

''' Type your code here '''

with the following lines of code:

price1 = services[service_choice1]

price2 = 0

if not (service_choice2 == "-"):

   price2 = services[service_choice2]

total = base_wash + price1 + price2

print("Zycar Wash")

print("Base car wash: $"+str(base_wash))

print(service_choice1+str(": $")+str(price1))

print(service_choice2+str(": $")+str(price2))

print("Total price: $"+str(total))

Explanation:

The complete program with explanation is as follows:

The italicized lines were originally part of the question

services = { 'Air freshener' : 1 , 'Rain repellent': 2, 'Tire shine' : 2, 'Wax' : 3, 'Vacuum' : 5 }

base_wash = 10

total = 0

service_choice1 = input()

service_choice2 = input()

This line gets the price of service choice 1

price1 = services[service_choice1]

This line initialzes price of service choice 2 to 0

price2 = 0

If an additional service (i.e. service choice 2) is selected

if not (service_choice2 == "-"):

This line gets the price of service choice 2

   price2 = services[service_choice2]

This calculates the total price

total = base_wash + price1 + price2

This prints the header

print("Zycar Wash")

This prints the base car wash

print("Base car wash: $"+str(base_wash))

This prints the service choice 1

print(service_choice1+str(": $")+str(price1))

This prints the service choice 2

print(service_choice2+str(": $")+str(price2))

This prints the total

print("Total price: $"+str(total))

Go Question: Other Questions