Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #code starts here
- rentalCode = input("(B)udget, (D)aily, or (W)eekly rental?\n")
- #variables
- budget_charge = 40.00
- daily_charge = 60.00
- weekly_charge = 190.00
- # rentalCode is a variable whos values changes with user input, and also has a string attached
- if rentalCode == "B" or rentalCode == "D":
- rentalPeriod = input("Number of Days Rented:\n");
- elif rentalCode == "W":
- rentalPeriod = input("Number of Weeks Rented:\n")
- if rentalCode == "B":
- baseCharge = int(rentalPeriod) * int(budget_charge)
- elif rentalCode == "D":
- baseCharge = int(rentalPeriod) * int(daily_charge)
- elif rentalCode == "W":
- baseCharge = int(rentalPeriod) * int(weekly_charge)
- print("%.2f" %baseCharge)
- #Odometer readings are variables that have numerical values and strings attached
- odoStart = input("Starting Odometer Reading:\n")
- odoEnd = input("Ending Odometer Reading:\n")
- totalMiles = int(odoEnd) - int(odoStart)
- #charge calcultor starts with IF Branch
- if rentalCode == "B":
- mileCharge = totalMiles * 0.25
- # ELIF is our secondary brach statement, revering to if the rental is based in Days
- elif rentalCode == "D":
- averageDayMiles = float(totalMiles)/float(rentalPeriod)
- if float(averageDayMiles) <= 100:
- extraMiles = 0
- # Our ELSE statement is the last Branch in a statment
- else:
- extraMiles = float(averageDayMiles) - 100
- mileCharge = (0.25 * float(extraMiles)) * float(rentalPeriod)
- elif rentalCode == "W":
- #here we are modifiying variables with operators to find our mile charge
- averageWeekMiles = float(totalMiles)/float(rentalPeriod)
- if averageWeekMiles <= 900:
- mileCharge = 0
- else:
- mileCharge = 100 * float(rentalPeriod)
- amtDue = baseCharge + mileCharge
- print("Rental Summary ")
- print("Rental Code: " + str(rentalCode))
- print("Rental Period: " + str(rentalPeriod))
- print("Starting Odometer: " + str(odoStart))
- print("Ending Odometer: " + str(odoEnd))
- print("Miles Driven: " + str(totalMiles))
- print("Amount Due: " + "$" + str("%.2f" %amtDue))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement