Advertisement
Guest User

Untitled

a guest
Nov 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.38 KB | None | 0 0
  1. import sys
  2.  
  3. class Service:
  4.   def __init__(self, name, price):
  5.     self.name = name
  6.     self.price = price
  7.  
  8. oil = Service("Oil change", 35)
  9. tire_rotation = Service("Tire rotation", 19)
  10. car_wash = Service("Car wash", 7)
  11. car_wax = Service("Car wax", 12)
  12.  
  13. services = [ oil, tire_rotation, car_wash, car_wax ]
  14.  
  15. def main():
  16.   print("Davy's auto shop services")
  17.   for service in services:
  18.     print('%s -- $%s' %(service.name, service.price))
  19.  
  20.   print('')
  21.  
  22.   first_service_name = input('Select first service: ')
  23.  
  24.   print('')
  25.  
  26.   second_service_name = input('Select second service: ')
  27.  
  28.   print('')
  29.  
  30.   for service in services:
  31.     if service.name == first_service_name:
  32.       first_service = service
  33.     elif service.name == second_service_name:
  34.       second_service = service
  35.  
  36.   print("Davy's auto shop invoice \n")
  37.  
  38.  
  39.   if (first_service_name == '-'):
  40.     print('Service 1: No Service')
  41.     first_service_price = 0
  42.   else:
  43.     print('Service 1: %s, $%s' %(first_service.name, first_service.price))
  44.     first_service_price = first_service.price
  45.  
  46.   if (second_service_name == '-'):
  47.     print('Service 2: No Service')
  48.     second_service_price = 0
  49.   else:
  50.     print('Service 2: %s, $%s' %(second_service.name, second_service.price))
  51.     second_service_price = second_service.price
  52.  
  53.   print('')
  54.  
  55.   print('Total: $%s' %(first_service_price + second_service_price))
  56.  
  57. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement