In: Computer Science
Rental Summary
Calculate the Amount Due.
amtDue = baseCharge + mileCharge
Print the Customer summary as follows:
Rental Summary Rental Code: The rental code Rental Period: The number of days the vehicle was rented Starting Odometer: The vehicle's odometer reading at the start of the rental period Ending Odometer: The vehicle's odometer reading at the end of the rental period Miles Driven: The number of miles driven during the rental period Amount Due: The amount of money billed displayed with a dollar sign and rounded to two digits. For example, $125.99 or $43.87
Final Check
Remove ALL print code from your script, except for the Rental
Summary.
The following data will be used in this final check:
Rental Code: D Rental Period: 5 Starting Odometer: 1234 Ending Odometer: 2222
Your final output should look like this:
Rental Code: D
Rental Period: 5
Starting Odometer: 1234
Ending Odometer: 2222
Miles Driven: 988
Amount Due: $324.40
Rental Summary Feedback Link
Before you submit your final code file for grading, it might be a good idea to get some feedback as a final check. This feedback is for your benefit and this will not submit your code for grading.
If so, click the Help Me! link below.
Help Me!
import sys
'''
Section 1: Collect customer input
'''
##Collect Customer Data - Part 1
##1) Request Rental code:
#Prompt --> "(B)udget, (D)aily, or (W)eekly rental?"
#rentalCode = ?
rentalCode = input("(B)udget, (D)aily, or (W)eekly
rental?\n")
print(rentalCode)
budget_charge = 40.00
daily_charge = 60.00
weekly_charge = 190.00
#2) Request time period the car was rented.
#Prompt --> "Number of Days Rented:"
#rentalPeriod = ?
# OR
#Prompt --> "Number of Weeks Rented:"
#rentalPeriod = ?
if rentalCode == 'B' or rentalCode == 'D':
rentalPeriod= int(input('Number of Days Rented:\n'))
else:
rentalPeriod =int(input('Number of Weeks Rented:\n'))
daysRented = rentalPeriod
#CUSTOMER DATA CHECK 1
#ADD CODE HERE TO PRINT:
#rentalCode
#rentalPeriod
#Calculation Part 1
##Set the base charge for the rental type as the variable
baseCharge.
#The base charge is the rental period * the appropriate rate:
#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 = ?
#b) Prompt the user to input the ending odometer
reading and store it as the variable odoEnd
#Prompt -->"Ending Odometer Reading:"
# odoEnd = ?
#c) Calculate total miles
#Print odoStart, odoEnd and 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
#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)
# ii) If averageDayMiles is above the 100 mile per
day
# limit:
# (1) calculate extraMiles (averageDayMiles -
100)
# (2) mileCharge is the charge for extraMiles,
# $0.25 for each mile
#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
'''
Section 3: Display the results to the customer
'''
#1) Calculate the Amount Due as the variable amtDue
# This is the base charge + mile charge
#2. Display the results of the rental calculation:
print ("Rental Summary")
print("Rental Code: ", rentalCode)
print ("Rental Period: ", rentalPeriod)
print ("Starting Odometer: ", odoStart)
print ("Ending Odometer: ", odoEnd)
print ("Miles Driven: ", totalMiles)
print ("Amount Due: ", amtDue)
import sys # Collecting Customer Data Part-1 rentalCode = input("(B)udget, (D)aily, or (W)eekly rental?\n") # print(rentalCode) budget_charge = 40.00 daily_charge = 60.00 weekly_charge = 190.00 if (rentalCode == 'B' or rentalCode == 'D'): rentalPeriod = int(input('Number of Days Rented:\n')) else: rentalPeriod = int(input('Number of Weeks Rented:\n')) # Customer Data Check 1 if (rentalCode == 'B'): baseCharge = float(rentalPeriod * budget_charge) elif (rentalCode == 'D'): baseCharge = float(rentalPeriod * daily_charge) else: baseCharge = float(rentalPeriod * weekly_charge) # print("Base Charge=", baseCharge) # Collecting Customer Data Part-2 odoStart = int(input("Starting Odometer Reading:\n")) odoEnd = int(input("Ending Odometer Reading:\n")) totalMiles = odoEnd - odoStart # Calculate Charges 2 averageDayMiles = float(totalMiles / rentalPeriod) if (rentalCode == 'B'): mileCharge = float(0.25 * totalMiles) elif (rentalCode == 'D'): if (averageDayMiles > 100): extraMiles = averageDayMiles - 100 mileCharge = float(extraMiles * 0.25) else: mileCharge = 0 else: if (averageDayMiles > 900): mileCharge = float(rentalPeriod * 100) # print("Mile Charge", mileCharge) amtDue = baseCharge + mileCharge # Displaying Results to the Customer print("Rental Summary") print("Rental Code: ", rentalCode) print("Rental Period: ", rentalPeriod) print("Starting Odometer: ", odoStart) print("Ending Odometer: ", odoEnd) print("Miles Driven: ", totalMiles) print("Amount Due: $%.2f" % amtDue, sep='')