Question
Project 1: Rental Car Introduction Your task for this project is to create a very simple rental car cost estimator. The project is broken into
Project 1: Rental Car
Introduction
Your task for this project is to create a very simple rental car cost estimator. The project is broken into three sections:
Collect customer input
Calculate the costs from the customer input
Display the results to the customer
Your final output should look like this:
Rental Code: D Rental Period: 5 Starting Odometer: 1234 Ending Odometer: 2222 Miles Driven: 988 Amount Due: $422.00
import sys
'''
Section 1: Collect customer input
'''
rentalCode = raw_input('(B)udget, (D)aily, or (W)eekly rental? ')
if rentalCode == 'B' or rentalCode == 'D':
rentalPeriod = int(raw_input('Number of Days Rented: '))
else:
rentalPeriod = int(raw_input('Number of Weeks Rented: '))
daysRented = rentalPeriod
#Assigning a dollar amount (double floating number) to the varying rates
budget_charge = 40.00
daily_charge = 60.00
weekly_charge = 190.00
#baseCharge changes value based on the type of rental code using multiplication
#Each branch of if or elif assignes a different value to the baseCharge which will impact the amtDue
#which will impact the amtDue
if rentalCode == 'B':
baseCharge = daysRented * budget_charge
elif rentalCode == 'D':
baseCharge = daysRented * daily_charge
elif rentalCode == 'W':
baseCharge = daysRented * weekly_charge
#print(rentalCode)
#print(rentalPeriod)
odoStart = input('Starting Odometer Reading: ')
odoEnd = input('Ending Odometer Reading: ')
#print(odoStart)
#print(odoEnd)
#print(baseCharge)
'''
Section 2: Calculate the costs from the customer input
'''
totalMiles = int(odoEnd) - int(odoStart)
print(totalMiles)
if rentalCode == 'B':
mileCharge = 0.25 * totalMiles
averageDayMiles = totalMiles/daysRented
if rentalCode == 'D' and averageDayMiles < 100:
mileCharge = 0
if averageDayMiles > 100 and rentalCode == 'D':
extraMiles = averageDayMiles - 100
mileCharge = extraMiles * 0.25
weeksRented = rentalPeriod
averageMiles = totalMiles/weeksRented
if rentalCode == 'W' and averageMiles > 900:
mileCharge = weeksRented * 100.00
else:
mileCharge = 0
print(mileCharge * rentalPeriod)
'''
Section 3: Display the results to the customer
'''
amtDue = baseCharge + mileCharge
#print('Rental Summary')
#print('Rental Code: '+str(rentalCode))
#print('Rental Period: '+str(rentalPeriod))
#print('Starting Odometer: '+odoStart)
#print('Ending Odometer: '+odoEnd)
#print('Miles Driven: '+str(totalMiles))
#print('Amount Due: '+'${:,.2f}'.format(amtDue))
#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: "
# odoStart = ?
#b) Prompt the user to input the ending odometer reading and store it as the variable odoEnd
#Prompt -->"Ending Odometer Reading:"
# odoEnd = ?
#CUSTOMER DATA CHECK 2
#ADD CODE HERE TO PRINT:
#odoStart
#odoEnd
#baseCharge
'''
Section 2: Calculate the costs from the customer input
'''
#1) Calculate the mileage.
#a) Calculate the total mileage:
# ending odometer reading - starting odometer reading
# and store it as the variable totalMiles
# totalMiles = ?
#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/daysRented)
# 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/ weeksRented)
# 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:
#Customer Summary
#Rental Code:
#Days Rented:
#Starting Odometer:
#Ending Odometer:
#Miles Driven:
#Amount Due: import sys
'''
Section 1: Collect customer input
'''
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: '))
daysRented = rentalPeriod
#Assigning a dollar amount (double floating number) to the varying rates
budget_charge = 40.00
daily_charge = 60.00
weekly_charge = 190.00
#baseCharge changes value based on the type of rental code using multiplication
#Each branch of if or elif assignes a different value to the baseCharge which will impact the amtDue
if rentalCode == 'B':
baseCharge = daysRented * budget_charge
elif rentalCode == 'D':
baseCharge = daysRented * daily_charge
elif rentalCode == 'W':
baseCharge = daysRented * weekly_charge
#print(rentalCode)
#print(rentalPeriod)
odoStart = input('Starting Odometer Reading: ')
odoEnd = input('Ending Odometer Reading: ')
#print(odoStart)
#print(odoEnd)
#print(baseCharge)
'''
Section 2: Calculate the costs from the customer input
'''
totalMiles = int(odoEnd) - int(odoStart)
print(totalMiles)
if rentalCode == 'B':
mileCharge = 0.25 * totalMiles
averageDayMiles = totalMiles/daysRented
if rentalCode == 'D' and averageDayMiles < 100:
mileCharge = 0
if averageDayMiles > 100 and rentalCode == 'D':
extraMiles = averageDayMiles - 100
mileCharge = extraMiles * 0.25
weeksRented = rentalPeriod
averageMiles = totalMiles/weeksRented
if rentalCode == 'W' and averageMiles > 900:
mileCharge = weeksRented * 100.00
else:
mileCharge = 0
'''
Section 3: Display the results to the customer
'''
amtDue = baseCharge + mileCharge
#print('Rental Summary')
#print('Rental Code: '+str(rentalCode))
#print('Rental Period: '+str(rentalPeriod))
#print('Starting Odometer: '+odoStart)
#print('Ending Odometer: '+odoEnd)
#print('Miles Driven: '+str(totalMiles))
#print('Amount Due: '+'${:,.2f}'.format(amtDue))
#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: "
# odoStart = ?
#b) Prompt the user to input the ending odometer reading and store it as the variable odoEnd
#Prompt -->"Ending Odometer Reading:"
# odoEnd = ?
#CUSTOMER DATA CHECK 2
#ADD CODE HERE TO PRINT:
#odoStart
#odoEnd
#baseCharge
'''
Section 2: Calculate the costs from the customer input
'''
#1) Calculate the mileage.
#a) Calculate the total mileage:
# ending odometer reading - starting odometer reading
# and store it as the variable totalMiles
# totalMiles = ?
#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/daysRented)
# 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/ weeksRented)
# 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:
#Customer Summary
#Rental Code:
#Days Rented:
#Starting Odometer:
#Ending Odometer:
#Miles Driven:
#Amount Due:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started