Question

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 (W)eekly rental?\n")

# For Budget type rental
if rentalCode.upper() == "B":
# Reading number of miles
total_miles = int(input("\n Input total number of miles driven: "))
  
# Calculating mileCharge
mileCharge = total_miles * 0.25

# For Daily type rental
elif rentalCode.upper() == "D":
# Reading number of miles and number of days rented
total_miles = int(input("\n Input total number of miles driven: "))
# daysRented = int(input("\n Input number of days rented: "))
  
# Calculating average miles
# averageDayMiles = total_miles/daysRented
  
# Checking for average miles
# if averageDayMiles <= 100:
# Set mileCharge to 0
# mileCharge = 0;
# else:
# Calculating mileCharge
# mileCharge = 0.25 * (averageDayMiles - 100) * daysRented
  
# For Weekly type rental
elif rentalCode.upper() == "W":
# Reading number of miles and number of weeks rented
total_miles = int(input("\n Input total number of miles driven: "))
weeksRented = int(input("\n Input number of weeks rented: "))
  
# Calculating average miles per week
averageWeekMiles = total_miles/ weeksRented
  
# Checking for average miles
if averageWeekMiles <= 900:
# Set mileCharge to 0
mileCharge = 0;
else:
# Calculating mileCharge
mileCharge = 100.0 * (averageDayMiles - 900) * weeksRented
  
mmmxx
else:
print("\n Invalid rental type selected... \n");
  
  
print("\n\n Mile Charge: $%.2f \n\n" %(mileCharge));

***** ATTENTION*******

Expected OUTPUT:

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

Number of Days Rented:

D

5

300.00

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Let me know if you have any doubt.

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 (W)eekly rental?\n")

# For Budget type rental
if rentalCode.upper() == "B":
    # Reading number of miles
    total_miles = int(input("\n Input total number of miles driven: "))

    # Calculating mileCharge
    mileCharge = total_miles * 0.25

# For Daily type rental
elif rentalCode.upper() == "D":
    # Reading number of miles and number of days rented
    total_miles = int(input("\n Input total number of miles driven: "))
    daysRented = int(input("\n Input number of days rented: "))

    # Calculating average miles
    averageDayMiles = total_miles/daysRented

    #Checking for average miles
    if averageDayMiles <= 100:
        #Set mileCharge to 0
        mileCharge = 0;
    else:
        #Calculating mileCharge
        mileCharge = 0.25 * (averageDayMiles - 100) * daysRented

# For Weekly type rental
elif rentalCode.upper() == "W":
    # Reading number of miles and number of weeks rented
    total_miles = int(input("\n Input total number of miles driven: "))
    weeksRented = int(input("\n Input number of weeks rented: "))

    # Calculating average miles per week
    averageWeekMiles = total_miles/ weeksRented

    # Checking for average miles
    if averageWeekMiles <= 900:
        # Set mileCharge to 0
        mileCharge = 0;
    else:
        # Calculating mileCharge
        mileCharge = 100.0 * (averageDayMiles - 900) * weeksRented

else:
    print("\n Invalid rental type selected... \n");


print("\n\n Mile Charge: $%.2f \n\n" %(mileCharge));
Add a comment
Know the answer?
Add Answer to:
Calculate the base charge if rentalCode == 'B': baseCharge = rentalPeriod * budgetCharge Set the base...
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...

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

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

  • Collect Customer Data - Part 1 Hint: This input code is similar to the code in...

    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!SHOW DIFF...

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

  • 1. Write a python script that will compute and display information for a company which rents...

    1. Write a python script that 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 after prompting the user to enter the following four items for a given customer (in the specified order)  The car type (a character either C (compact), M (mid-size), L (luxury), S (SUV), or V (Van) )  The number...

  • Need help Purpose Calculate mileage reimbursements using arrays and methods. The Mathematical Association of America hosts...

    Need help Purpose Calculate mileage reimbursements using arrays and methods. The Mathematical Association of America hosts an annual summer meeting. Each state sends one official delegate to the section officers’ meeting at this summer session. The national organization reimburses the official state delegates according to the scale below. Write a Java program to calculate the reimbursement values, satisfying the specifications below. Details on array and method usage follow these specs. 1. The main method should declare all the variables at...

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