ParkingCharge
shinta0x01
python
2 years ago
2.0 kB
8
Indexable
print("C for Car \nB for Bus \nT for Truck\n")
typeVehicle = input("Type of Vehicle? ")
hourEntered = int(input("Hour vehicle entered lot: "))
minEntered = int(input("Minute vehicle entered lot: "))
hourLeft = int(input("Hour vehicle left lot: "))
minLeft = int(input("Minute vehicle left lot: "))
totalMinutes = (hourLeft - hourEntered) * 60 + (minLeft - minEntered)
hoursPark = totalMinutes // 60
remMinutes = totalMinutes % 60
roundHour = hoursPark + (remMinutes > 0)
charge = 0
if typeVehicle in ("C", "c"):
typeVehicle = "Car"
baseRate = 0.00
if roundHour <= 3:
charge = baseRate
elif roundHour > 3:
charge = (roundHour - 3) * 1.50
elif typeVehicle in ("T", "t"):
typeVehicle = "Truck"
baseRate = 1.00
if roundHour <= 2:
charge = baseRate * roundHour
elif roundHour > 2:
firstRate = 2 * baseRate
charge = firstRate + (roundHour - 2) * 2.30
elif typeVehicle in ("B", "b"):
typeVehicle = "Bus"
baseRate = 2.00
if roundHour <= 1:
charge = baseRate * roundHour
elif roundHour > 1:
charge = baseRate + (roundHour - 1) * 3.70
else:
print("Input the correct initial for your vehicle!")
exit()
if hourLeft >= 24 or minLeft >= 60:
print("No vehicle is allowed to stay in the parking lot later than midnight; IT WILL BE TOWED AWAY")
exit()
elif hourEntered < 0 or hourEntered >= 24 or minEntered < 0 or minEntered >= 60:
print("Time values (hour and minute) within the expected range (0-23 for hours and 0-59 for minutes) ")
exit()
print("\n\tPARKING LOT CHARGE")
print("Type of vehicle: " + typeVehicle)
print("TIME-IN\t\t\t" + str(hourEntered) + ":" + str(minEntered).zfill(2))
print("TIME-OUT\t\t" + str(hourLeft) + ":" + str(minLeft).zfill(2))
print("\t\t\t")
print("PARKING TIME \t" + str(totalMinutes // 60) + ":" + str(totalMinutes % 60).zfill(2))
print("ROUNDED TOTAL\t" + str(roundHour))
print("\t\t\t")
print("TOTAL CHARGE\t" + format(charge, '.2f'))Editor is loading...
Leave a Comment