Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

As you work through the project guide, be aware that before you submit the script draft you will need to add comments to meet the requirements found in the IT-140 Project One Guidelines and Rubric: Rental Car Script Draft document.

Although these comments can be added after you complete the guide, you will likely find it useful to add as much as possible while you work through the script.

Collect Customer Data - Part 1

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.

Add code to PRINT the rentalCode and rentalPeriodvariables to check your work.

The following data will be used as input in the first check:

rentalCode = 'D' rentalPeriod = 5 

Customer Data Check 1A

Check It!

LAST RUN on 11/19/2018, 12:05:03 PM

 

Check 1 passed

The following data will be used as input in the second check:

rentalCode = 'W' rentalPeriod = 1 

Customer Data Check 1B

Check It!

LAST RUN on 11/19/2018, 12:05:03 PM

Check 1 passed

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 = ?

Test your code.

Collect Customer Data - Part 2

Collect Mileage information:

Prompt: "Starting Odometer Reading: "

Variable: odoStart = ?

Prompt: "Ending Odometer Reading: "

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 

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

Check It!

LAST RUN on 11/19/2018, 12:06:00 PM

Check 1 passed

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)

Test your code.

Next

Calculate Charges - Part 1

Calculate the base charge

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

'''

Section 1: Collect customer input

'''

#This line of code is prompting the user to enter one of three values:

#Values: B-budget, D-daily, and W-weekly

#

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

#This line of Code is

if rentalCode == "W":

rentalPeriod = int(input("Number of Weeks Rented: "))

else:

rentalPeriod = int(input("Number of Days Rented: "))

print(rentalCode)

print(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:

if rentalCode == 'B':

baseCharge = rentalPeriod * budgetCharge

print(baseCharge)

#Collect Customer Data - Part 2

#input the starting odometer reading

odoStart = int(input('Starting Odometer Reading: '))

#odoStart variable = 1234

#input the ending odometer reading

##odoEnd variable = 2222

odoEnd = int(input('Ending Odometer Reading: '))

totalMiles = int(odoEnd) - int(odoStart)

print(odoStart)

print(odoEnd)

print(totalMiles)

# Calculate Charges 2

## Calculate the mileage charge and store it as

# the variable mileCharge:

if rentalCode == "B":

baseCharge = rentalPeriod * budgetCharge

mileCharge = totalMiles * 0.25

print(baseCharge)

#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)

#

if rentalCode == "D":

averageDay Miles = totalMiles/rentalPeriod

if averageDayMiles > 100:

extraMiles = averageDayMiles - 100

else:

extraMiles = 0

mileCharge = extraMiles * 0.25

print(mileCharge+extraMiles)

# 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;

#

if rentalCode == "W":

averageWeekMiles = totalMiles/rentalPeriod

if averageWeekMiles > 900:

mileCharge = 100 * rentalPeriod

else:

mileCharge = 0

print(mileCharge * rentalPeriod)

This is what i keep getting

Add code to PRINT the baseCharge to check your work.

The following data will be used as input in the test:

rentalCode = 'D' rentalPeriod = 5 

Calculate Charges 1

Add code to print the value of baseCharge variable.

Check It!SHOW DIFF

LAST RUN on 11/19/2018, 12:06:54 PM

 

Check 1 failed

Output:

(B)udget, (D)aily, or (W)eekly rental? Number of Days Rented: D 5

Expected:

(B)udget, (D)aily, or (W)eekly rental? Number of Days Rented: D 5 300.00

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.

This is where i am having issues, im stuck and feel very frazzled.

This is what I have so far.

import sys

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

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

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

Answered: 1 week ago