Introduction
Your task for this project is to create a very simple rental car cost estimator. The project is broken into three sections:
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
_______________________________________
Section 1-1:
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 = ?
#2) Request time period the car was rented.
#Prompt --> "Number of Days Rented:"
#rentalPeriod = ?
# OR
#Prompt --> "Number of Weeks Rented:"
#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:
____________________________________________________________________
Section 1-2:
import sys
'''
Section 1: Collect customer input
'''
#Add customer input 1 here, 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 = ?
#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 2-1:
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 = ?
#2) Request time period the car was rented.
#Prompt --> "Number of Days Rented:"
#rentalPeriod = ?
# OR
#Prompt --> "Number of Weeks Rented:"
#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:
___________________________________________________________
Section 2-2:
import sys
'''
Section 1: Collect customer input
'''
#Add customer input 1 here, 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 = ?
#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-1:
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 = ?
#2) Request time period the car was rented.
#Prompt --> "Number of Days Rented:"
#rentalPeriod = ?
# OR
#Prompt --> "Number of Weeks Rented:"
#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-2:
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 = ?
#2) Request time period the car was rented.
#Prompt --> "Number of Days Rented:"
#rentalPeriod = ?
# OR
#Prompt --> "Number of Weeks Rented:"
#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
____________________________________________________________________________________________
Please include code that can be copied and screenshots for indents. Thank you.
If you have any doubts, please give me comment...
import sys
#ask user for input of type of rental
rentalCode = input ("(B)udget, (D)aily, or (W)eekly rental? ")
if rentalCode == "B" or rentalCode == "D":
rentalPeriod = int(input("Number of Days Rented: "))
else:
rentalPeriod = int(input("Number of Weeks Rented: "))
budgetCharge = 40.00
dailyCharge = 60.00
weeklyCharge = 190.00
if rentalCode == "B":
#calulate charges depending on input from above
baseCharge= rentalPeriod * 40.00
elif rentalCode == "D":
baseCharge= rentalPeriod * 60.00
else:
baseCharge= rentalPeriod * 190.00
odoStart = int(input("Starting Odometer Reading: "))
#b) Prompt the user to input the ending odometer reading and store it as the variable odoEnd
odoEnd = int(input("Ending Odometer Reading: "))
#calulate miles driven
totalMiles = int(odoEnd) - int(odoStart)
#calulating of charges based on miles driven and rental type
averageDayMiles = 0
if rentalCode == "B" :
mileCharge = totalMiles*0.25
elif rentalCode == "D":
averageDayMiles = totalMiles/rentalPeriod
if averageDayMiles <=100 :
extraMiles = 0
else:
extraMiles = float(averageDayMiles - 100)
mileCharge = float(extraMiles*0.25)
else:
averageWeeklyMiles = totalMiles/rentalPeriod
if averageWeeklyMiles <=900:
extraMiles = 0
else:
extraMiles = float(totalMiles - 900)
mileCharge += float(extraMiles*100)
amtDue = baseCharge + mileCharge
print("Rental Code: "+rentalCode)
print("RentalPeriod: " + str(rentalPeriod))
print("Starting Odometer: " + str(odoStart))
print("Ending Odometer: " + str(odoEnd))
print("Miles Driven:: " + str(totalMiles))
print("Amount Due: $%.2f"%amtDue)
Get Answers For Free
Most questions answered within 1 hours.