Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Hint: This input code is similar to the code in the previous step but use a conditional statement to test if the rentalPeriod is a daily or weekly rental then set the user input equal to rentalPeriod.

Request Rental Code. Prompt the user to input the Rental Code.

Prompt: "(B)udget, (D)aily, or (W)eekly rental? " Variable: rentalCode = ?

The code options are:

Code Category Rate
B budget budget_charge = 40.00
D daily daily_charge = 60.00
W weekly weekly_charge = 190.00

Set the user input equal to rentalCode.

rentalCode = input("(B)udget, (D)aily, or (W)eekly rental? ") 

Request number of days or weeks the car was rented.Prompt: "Number of Days Rented: "

OR

Prompt: "Number of Weeks Rented: "

Variable: rentalPeriod = ?

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

budgetCharge = 40.00

dailyCharge = 60.00

weeklyCharge = 190.00

##Set the base charge for the rental type as the variable baseCharge.

#The base charge is the rental period * the appropriate rate:

Collect Mileage information:

Prompt: "Starting Odometer Reading: "

Variable: odoStart = ?

Prompt: "Ending Odometer Reading: "

Variable: odoEnd = ?

Prompt the user to input the starting odometer reading (expect type int from the user)

Prompt the user to input the ending odometer reading (expect type int from the user)

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)

#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: "

# 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

Calculate Charges - Part 1

Calculate the base charge

if rentalCode == 'B': baseCharge = rentalPeriod * budgetCharge 

Set the base charge for the rental type equal to the variable baseCharge. The base charge is the rental period * the appropriate rate: For example:

Finish the conditional statement by adding the conditions for other rental codes.

Test your code.

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

budgetCharge = 40.00

dailyCharge = 60.00

weeklyCharge = 190.00

##Set the base charge for the rental type as the variable baseCharge.

#The base charge is the rental period * the appropriate rate:

Expected:

(B)udget, (D)aily, or (W)eekly rental?

Number of Days Rented:

D

5

300.00

Calculating Charges - Part 2

Calculate the mileage charge

Depending on the rental type, the mileage charge is calculated differently. You will need to create add code to calculate the mileage charge for each type of rental. Store the cost of miles drive as the variable mileCharge

Set the user input equal to rentalCode.

rentalCode = input("(B)udget, (D)aily, or (W)eekly rental? ") 

Prompt the user to input the Rental Code.

Prompt: "(B)udget, (D)aily, or (W)eekly rental? " Variable: rentalCode = ?

Code B (budget) mileage charge: $0.25 for each mile driven

mileCharge = totalMiles x 0.25

Code D (daily) mileage charge: no charge if the average number of miles driven per day is 100 miles or less;

mileCharge = .25 x extraMiles x rentalPeriod

Calculate the averageDayMiles = totalMiles/rentalPeriodIf averageDayMiles is 100 or less,

extraMiles = 0

If averageDayMiles is above the 100 mile per day limit, calculate:

extraMiles = averageDayMiles - 100

Calculate the cost of the extra miles:

extraMiles x $0.25

Code `W` (weekly) mileage charge: no charge if the average number of miles driven per week is 900 miles or less.Calculate the average weekly miles

averageWeekMiles = totalMiles/ rentalPeriod

If the average number of miles driven per week exceeds 900 miles, the mileCharge is $100.00 per week, otherwise, the mileCharge is $0.00

*****

Expected:

(B)udget, (D)aily, or (W)eekly rental?

B

Starting Odometer Reading:

Ending Odometer Reading:

1234

2222

988

247.00

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

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

budgetCharge = 40.00

dailyCharge = 60.00

weeklyCharge = 190.00

##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: "

# 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

Expected:

(B)udget, (D)aily, or (W)eekly rental?

Number of Days Rented:

Starting Odometer Reading:

Ending Odometer Reading:

Rental Summary

Rental Code: D

Rental Period: 5

Starting Odometer: 1234

Ending Odometer: 2222

Miles Driven: 988

Amount Due: $324.40

*****Please show the work so I may see the proper indention*******

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions

Question

Different formulas for mathematical core areas.

Answered: 1 week ago

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago