I am currently working on a project for my CSE class and we are meant to ask users for information on their car rental, then print out their balance and other information. Each user has either a budget (B), daily (D), or weekly (W) code which all have different equations for calculating the final balance of the account. I tried to use if and elif statements for each codes, however I keep getting an invalid syntax error while nesting if statements inside of an elif statement. How could I resolve this error to continue working on the project? Thank you!
answer = input("Would you like to continue? (Y/N)? ")
while answer == 'Y' or answer == 'y': #user inputs information if they reply yes to the prompt
customer_code = input("Please enter Customer code (B/D/W): ")
days_rented = int(input("Please enter the number of days rented: "))
initial_miles = int(input("Please enter the original mileage of the rental: "))
final_miles = int(input("Please enter the new mileage of the rental: "))
mileage = final_miles - initial_miles #calculating other information
weeks = (days_rented / 7)
average_miles_d = mileage / days_rented
average_miles_y = mileage / weeks
if customer_code == 'B': #budget customer
balance = ((40 * days_rented) + (.25 * mileage))
elif customer_code == 'D': #daily customer
if average_miles_d < 100:
balance = ((60 * days_rented)
elif average_miles_d >= 100:
balance = ((60 * days_rented) + (.25 * (average_miles - 100)))
elif customer_code == 'W': #weekly customer
if average_miles_w < 900:
balance = (190 * weeks)
elif average_miles_w > 900 and average_miles_w < 1500:
balance = (100 * weeks)
else:
balance = ((200 * weeks) + (.25 * (average_miles_w - 1500))
Aucun commentaire:
Enregistrer un commentaire