Question

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) Prompt the user to input the starting odometer reading and store it as the variable odoStart

#Prompt -->"Starting Odometer Reading:\n"
odoStart = input("Starting Odometer Reading:\n")

##b) Prompt the user to input the ending odometer reading and store it as the variable odoEnd

#Prompt -->"Ending Odometer Reading:"
odoEnd = input("Ending Odometer Reading:\n")

#c) Calculate total miles

print(int(odoStart))
print(int(odoEnd))
totalMiles = (int(odoEnd) - int(odoStart))
print(int(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
if rentalCode == 'B':
mileCharge = float(totalMiles) * 0.25

#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
if rentalCode == 'D' :
averageDayMiles = float(totalMiles)/float(rentalPeriod)
if(float(averageDayMiles)) <= 100:
extraMiles = 0
  
elif extraMiles == float(averageDayMiles) - 100:
mileCharge = (.25 * float(extraMiles)) * float(rentalPeriod)

#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
elif rentalCode == 'W':
averageWeekMiles = float(totalMiles)/float(rentalPeriod)
if averageWeekMiles <= 900:
mileCharge = 0
else:
mileCharge = 100 * float(rentalPeriod)
  
print("%.2f"%mileCharge)

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

In order to get the required output, changes to your code are made while taking input to rentalCode, odoStart and odoEnd .

CODE:

import sys
'''
Section 1: Collect customer input
'''
#Add customer input 1 here,
rentalCode = input("(B)udget, (D)aily, or (W)eekly rental?\n") #Add backslash n

#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 = input("Starting Odometer Reading:") #Remove backslash n

##b) Prompt the user to input the ending odometer reading and store it as the variable odoEnd

#Prompt -->"Ending Odometer Reading:"
odoEnd = input("Ending Odometer Reading:") #Remove backslash n

#c) Calculate total miles

print(int(odoStart))
print(int(odoEnd))
totalMiles = (int(odoEnd) - int(odoStart))
print(int(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
if rentalCode == 'B':
    mileCharge = float(totalMiles) * 0.25

#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
if rentalCode == 'D' :
    averageDayMiles = float(totalMiles)/float(rentalPeriod)
    if(float(averageDayMiles)) <= 100:
        extraMiles = 0
    elif extraMiles == float(averageDayMiles) - 100:
        mileCharge = (.25 * float(extraMiles)) * float(rentalPeriod)

#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
elif rentalCode == 'W':
    averageWeekMiles = float(totalMiles)/float(rentalPeriod)
    if averageWeekMiles <= 900:
        mileCharge = 0
    else:
        mileCharge = 100 * float(rentalPeriod)
        
        
print("%.2f"%mileCharge)

OUTPUT:

(B) udget, (Daily, or ( Weekly rental? Starting Odometer Reading: 1234 Ending Odometer Reading:2222 1234 2222 988 247.00

Add a comment
Know the answer?
Add Answer to:
what am I missing? this should be the output: (B)udget, (D)aily, or (W)eekly rental? B Starting...
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
  • 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...

  • 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...

  • BELOW CODE DONE IN CODIO AND PASSED THE FIRST SET OF CHECKS FOR COLLECT CUSTOMER DATA...

    BELOW CODE DONE IN CODIO AND PASSED THE FIRST SET OF CHECKS FOR COLLECT CUSTOMER DATA PART 2 (CODIO) CHECK INSTRUCTIONS BELOW - PASSED Collect Customer Data - Part 2 Collect Mileage information: Prompt: "Starting Odometer Reading:\n" Variable: odoStart = ? Prompt: "Ending Odometer Reading:\n" 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...

  • 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":...

  • 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...

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