In: Computer Science
IM GETTING A ERROR MESSAGE :
if rentalCode == 'W' and averageMiles <= 900:
mileCharge = weeksRented * 100.00
else:
Collect Customer Data - Part 2
Prompt: "Starting Odometer Reading:\n"
Variable: odoStart = ?
Prompt: "Ending Odometer Reading:\n"
Variable: odoEnd = ?
Add code to PRINT odoStart and odoEnd variables as well as the totalMiles to check your work.
The following data will be used as input in the test:
odoStart = 1234 odoEnd = 2222
Collect Customer Data - Part 2 - Feedback Link
IF you would like some constructive feedback on your assignment before you submit for a grade, press the Help Me! button below.
Help Me!
Customer Data Check 2
In your rental_car.py file, add code to print out the two new
variables you have collected input for:
odoStart
odoEnd
totalMiles
import sys
'''
Section 1: Collect customer input
'''
#Add customer input 1 here, rentalCode = ?
rentalCode = input("(B)udget, (D)aily, or (W)eekly
rental?\n")
print (rentalCode)
#Collect Customer Data - Part 2
#4)Collect Mileage information:
#a) Prompt the user to input the starting odometer
reading and store it as the variable odoStart
#Prompt -->"Starting Odometer Reading:\n"
# odoStart = ?
odoStart = input('Starting Odometer Reading: ')
#b) Prompt the user to input the ending odometer
reading and store it as the variable odoEnd
#Prompt -->"Ending Odometer Reading:"
# odoEnd = ?
odoEnd = input('Ending Odometer Reading: ')
#c) Calculate total miles
totalMiles = int(odoEnd) - int(odoStart)
#Print odoStart, odoEnd and totalMiles
print (odoStart)
print (odoEnd)
print (totalMiles)
# Calculate Charges 2
## Calculate the mileage charge and store it
as
# the variable mileCharge:
#a) Code 'B' (budget) mileage charge: $0.25 for each
mile driven
if rentalCode == "B":
mileCharge = totalMiles * 0.25
#b) Code 'D' (daily) mileage charge: no charge if the
average
# number of miles driven per day is 100 miles or less;
# i) Calculate the averageDayMiles
(totalMiles/rentalPeriod)
elif rentalCode == "D":
averageDayMiles = totalMiles/rentalPeriod
if averageDayMiles <= 100:
extraMiles == 0
# ii) If averageDayMiles is above the 100 mile per
day
# limit:
# (1) calculate extraMiles (averageDayMiles -
100)
if totalMiles >= 100 and rentalCode == 'D':
# (2) mileCharge is the charge for extraMiles,
mileCharge = totalMiles * int(rentalPeriod) *0.25
#c) Code 'W' (weekly) mileage charge: no charge if
the
# average number of miles driven per week is
# 900 miles or less;
if rentalCode == 'W' and averageMiles <= 900:
mileCharge = weeksRented * 100.00
else:
mileCharge = 0
# i) Calculate the averageWeekMiles (totalMiles/
rentalPeriod)
# ii) mileCharge is $100.00 per week if the average
number of miles driven per week exceeds 900 miles
if rentalCode == 'W' and averageMiles >= 900:
mileCharge = weeksRented * 100.00
else:
print('Charges : ${}'.format(mileCharge))
If you have any doubts, please give me comment...
import sys
'''
Section 1: Collect customer input
'''
#Add customer input 1 here, rentalCode = ?
rentalCode = input ("(B)udget, (D)aily, or (W)eekly rental? ")
print(rentalCode)
if rentalCode == "B" or rentalCode == "D":
rentalPeriod = int(input("Number of Days Rented: "))
else:
rentalPeriod = int(input("Number of Weeks Rented: "))
if rentalCode == "B":
baseCharge= rentalPeriod * 40.00
elif rentalCode == "D":
baseCharge= rentalPeriod * 60.00
else:
baseCharge= rentalPeriod * 190.00
#Collect Customer Data - Part 2
#4)Collect Mileage information:
#a) Prompt the user to input the starting odometer reading and store it as the variable odoStart
#Prompt -->"Starting Odometer Reading:\n"
# odoStart = ?
odoStart = int(input("Starting Odometer Reading: "))
#b) Prompt the user to input the ending odometer reading and store it as the variable odoEnd
#Prompt -->"Ending Odometer Reading:"
# odoEnd = ?
odoEnd = int(input("Ending Odometer Reading: "))
#c) Calculate total miles
totalMiles = int(odoEnd) - int(odoStart)
#Print odoStart, odoEnd and totalMiles
print (odoStart)
print (odoEnd)
print (totalMiles)
averageDayMiles = 0
# Calculate Charges 2
## Calculate the mileage charge and store it as
# the variable mileCharge:
#a) Code 'B' (budget) mileage charge: $0.25 for each mile driven
if rentalCode == "B" :
mileCharge = totalMiles*0.25
print("Charges: ${}".format(mileCharge))
#b) Code 'D' (daily) mileage charge: no charge if the average
# number of miles driven per day is 100 miles or less;
elif rentalCode == "D":
# i) Calculate the averageDayMiles (totalMiles/rentalPeriod)
# ii) If averageDayMiles is above the 100 mile per day
# limit:
# (1) calculate extraMiles (averageDayMiles - 100)
# (2) mileCharge is the charge for extraMiles,
averageDayMiles = totalMiles/rentalPeriod
if averageDayMiles <=100 :
extraMiles = 0
else:
extraMiles = float(averageDayMiles - 100)
mileCharge = float(extraMiles*0.25)
print("Charges: ${}".format(mileCharge))
#c) Code 'W' (weekly) mileage charge: no charge if the
# average number of miles driven per week is
# 900 miles or less;
# i) Calculate the averageWeekMiles (totalMiles/ rentalPeriod)
# ii) mileCharge is $100.00 per week if the average number of miles driven per week exceeds 900 miles
elif rentalCode == 'W':
averageWeeklyMiles = totalMiles/rentalPeriod
if averageWeeklyMiles <=900:
extraMiles = 0
else:
extraMiles = float(totalMiles - 900)
mileCharge += float(extraMiles*100)
print("Charges: ${}".format(mileCharge))
else:
print("Invalid rental code")