Question

Section 1: Collect customer input ''' rentalCode = input('(B)udget, (D)aily, or (W)eekly rental?\n') if rentalCode ==...

Section 1: Collect customer input
'''
rentalCode = input('(B)udget, (D)aily, or (W)eekly rental?\n')
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
#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:\n')
odoEnd = input('Ending Odometer Reading:\n')
#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:
extraMiles = 0
if averageDayMiles > 100 and rentalCode == 'D':
extraMiles = averageDayMiles - 100
mileCharge = 0.25 * extraMiles * rentalPeriod
weeksRented = rentalPeriod
averageMiles = totalMiles/weeksRented
if rentalCode == 'W' and averageDayMiles > 900:
mileCharge = weeksRented * 100.00
elif rentalCode == 'W' and averageDayMiles <= 900:
mileCharge = 0
  

'''
Section 3: Display the results to the customer
'''
#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:\n"
# 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:
'''
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: '+str(odoStart))
print('Ending Odometer: '+str(odoEnd))
print('Miles Driven: '+str(totalMiles))
print('Amount Due: '+'${:,.2f}'.format(amtDue))

Final Check: Rental Summary

on python

Check It!SHOW DIFF

LAST RUN on 11/18/2019, 4:27:06 PM

 

Check 1 failed

Output:

(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: $422.00

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

0 0
Add a comment Improve this question Transcribed image text
Answer #1


rentalCode=input('(B)udget, (D)aily, or (W)eekly rental?\n')
rentalPeriod=float(input("Number of Days/Weeks Rented:\n"))
budget_charge=40
daily_charge=60
weekly_charge=190
if rentalCode=='B':
baseCharge=rentalPeriod*budget_charge
elif rentalCode=='D':
baseCharge=rentalPeriod*daily_charge
else:
baseCharge=rentalPeriod*weekly_charge
odoStart=float(input("Starting Odometer Reading:\n"))
odoEnd=float(input("Ending Odometer reading:\n"))
totalMiles=odoEnd-odoStart
if rentalCode=='B':
mileCharge=totalMiles*.25
elif rentalCode=='D':
averageDayMiles=totalMiles/rentalPeriod
if averageDayMiles<=100:
extraMiles=0
else:
extraMiles=averageDayMiles-100
mileCharge=.25*extraMiles
else:
averageWeekMiles=totalMiles/rentalPeriod
if averageWeekMiles>900:
mileCharge=100*rentalPeriod
else:
mileCharge=0

amtDue = baseCharge + mileCharge
print('Rental Summary')
print('Rental Code: '+str(rentalCode))
print('Rental Period: '+str(rentalPeriod))
print('Starting Odometer: '+str(odoStart))
print('Ending Odometer: '+str(odoEnd))
print('Miles Driven: '+str(totalMiles))
print('Amount Due: '+'${:,.2f}'.format(amtDue))

Add a comment
Know the answer?
Add Answer to:
Section 1: Collect customer input ''' rentalCode = input('(B)udget, (D)aily, or (W)eekly rental?\n') if rentalCode ==...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • what am I missing? this should be the output: (B)udget, (D)aily, or (W)eekly rental? B Starting...

    what am I missing? this should be the output: (B)udget, (D)aily, or (W)eekly rental? B Starting Odometer Reading: Ending Odometer Reading: 1234 2222 988 247.00 my output is this: (B)udget, (D)aily, or (W)eekly rental? Starting Odometer Reading: Ending Odometer Reading: 1234 2222 988 247.00 here's my code so far: import sys ''' Section 1: Collect customer input ''' #Add customer input 1 here, rentalCode = input("(B)udget, (D)aily, or (W)eekly rental?") #Collect Customer Data - Part 2 #4)Collect Mileage information: ##a)...

  • Code comments explain and facilitate navigation of the code python import sys rentalcode = input("(B)udget, (D)aily,...

    Code comments explain and facilitate navigation of the code python import sys rentalcode = input("(B)udget, (D)aily, or (W)eekly rental?\n").upper() if rentalcode == 'B' or rentalcode == 'D': rentalperiod = int(input("Number of Days Rented:\n")) else: rentalperiod = int(input("Number of Weeks Rented:\n")) # Pricing budget_charge = 40.00 daily_charge = 60.00 weekly_charge = 190.00 #Second Section 2 odostart =int(input("Starting Odometer Reading:\n")) odoend =int(input("Ending Odometer Reading:\n")) totalmiles = int(odoend) - int(odostart) if rentalcode == 'B': milecharge = 0.25 * totalmiles if rentalcode == "D":...

  • I am completing a rental car project in python. I am having syntax errors returned. currently...

    I am completing a rental car project in python. I am having syntax errors returned. currently on line 47 of my code "averageDayMiles = totalMiles/daysRented" my entire code is as follows: #input variable rentalCode = input("(B)udget , (D)aily , (W)eekly rental? \n") if(rentalCode == "B"): rentalPeriod = int(input("Number of hours rented?\n")) if(rentalCode == "D"): rentalPeriod = int(input("Number of days rented?\n")) if(rentalCode == "W"): rentalPeriod = int(input("Number of weeks rented?\n")) rentalPeriod = daysRented return rentalCode , rentalPeriod budget_charge = 40.00 daily_charge...

  • Calculate the base charge if rentalCode == 'B': baseCharge = rentalPeriod * budgetCharge Set the base...

    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. import sys ''' Section 1: Collect customer input ''' # For holding cost of miles drive mileCharge = 0 # Reading type of rental rentalCode = input("(B)udget, (D)aily, or...

  • in Python The program will compute and display information for a company which rents vehicles to...

    in Python The program will compute and display information for a company which rents vehicles to its customers. For a specified customer, the program will compute and display the amount of money charged for that customer’s vehicle rental. 1. The program will repeatedly prompt the user to enter the following four items for a given customer (in the specified order): a. The customer's classification code (a character) b. The number of days the vehicle was rented (a number) c. The...

  • Propose: In this lab, you will complete a Python program with one partner. This lab will...

    Propose: In this lab, you will complete a Python program with one partner. This lab will help you with the practice modularizing a Python program. Instructions (Ask for guidance if necessary): To speed up the process, follow these steps. Download the ###_###lastnamelab4.py onto your desktop (use your class codes for ### and your last name) Launch Pyscripter and open the .py file from within Pyscripter. The code is already included in a form without any functions. Look it over carefully....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT