Calculating Charges - Part 2
Set the user input equal to rentalCode.
rentalCode = input("(B)udget, (D)aily, or (W)eekly rental?\n")
Prompt: "(B)udget, (D)aily, or (W)eekly rental?\n"
Variable: rentalCode = ?
mileCharge = totalMiles x 0.25
extraMiles = 0
If averageDayMiles is above the 100 mile per day limit, calculate:extraMiles = averageDayMiles - 100
extraMiles x $0.25
averageWeekMiles = totalMiles/ rentalPeriod
Answer: Hey! Kindly find your code here. If you have any queries, feel free to ask me, would be very happy to solve them. You didn't mention any language so I used pythonThanks.
print("Rental Code")
print("B-(Budget),D(Daily),W(Weekly)")
totalMiles = float(input("Enter total miles"))
rentalPeriod = float(input("Enter period of rental"))
averageDayMiles = totalMiles/rentalPeriod
averageWeekMiles = totalMiles/rentalPeriod
rentalCode = input("Enter rental code: ")
if rentalCode =="B":
mileCharge = totalMiles*0.25
print("Your mile charge is: $",mileCharge)
elif rentalCode == "D":
if averageDayMiles<=100:
extraMiles = 0
print("You have no charge")
else:
extraMiles =
averageDayMiles-100
mileCharge = extraMiles*0.25
print("Your mile charge is:
$",mileCharge)
elif rentalCode =="W":
if averageWeekMiles<=900:
mileCharge = 0
print("Your mile charge is: $",mileCharge)
else:
mileCharge = 100
print("Your mile charge is:
$",mileCharge)
Get Answers For Free
Most questions answered within 1 hours.