pacho_the_python

tax_calculator

Oct 22nd, 2023
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | None | 0 0
  1. vehicles = input().split('>>')
  2. total_tax = 0
  3.  
  4. while len(vehicles) > 0:
  5.     current_car = vehicles[0].split(' ')
  6.     years = int(current_car[1])
  7.     kilometers = int(current_car[2])
  8.     if current_car[0] == "family":
  9.         tax = 50
  10.         for year in range(1, years + 1):
  11.             tax -= 5
  12.         while kilometers - 3000 >= 0:
  13.             tax += 12
  14.             kilometers -= 3000
  15.         total_tax += tax
  16.         print(f"A {current_car[0]} car will pay {tax:.2f} euros in taxes.")
  17.     elif current_car[0] == "heavyDuty":
  18.         tax = 80
  19.         for year in range(1, years + 1):
  20.             tax -= 8
  21.         while kilometers - 9000 >= 0:
  22.             tax += 14
  23.             kilometers -= 9000
  24.         total_tax += tax
  25.         print(f"A {current_car[0]} car will pay {tax:.2f} euros in taxes.")
  26.     elif current_car[0] == "sports":
  27.         tax = 100
  28.         for year in range(1, years + 1):
  29.             tax -= 9
  30.         while kilometers - 2000 >= 0:
  31.             tax += 18
  32.             kilometers -= 2000
  33.         total_tax += tax
  34.         print(f"A {current_car[0]} car will pay {tax:.2f} euros in taxes.")
  35.     else:
  36.         print("Invalid car type.")
  37.  
  38.     vehicles.pop(0)
  39.  
  40. print(f"The National Revenue Agency will collect {total_tax:.2f} euros in taxes.")
Add Comment
Please, Sign In to add comment