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

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

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

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

  • 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. Please provide a C++ program which faithfully reads a list of non-negative integer scores, ultimately...

    1. Please provide a C++ program which faithfully reads a list of non-negative integer scores, ultimately terminating the list reading when the sentinel value (lets use -9999) is entered. The program should then correctly report the number of non-negative scores entered and the arithmetic mean (average) of those scores 2. Demonstrate your programs behavior in response to errors on input (that is, show that it faithfully rejects improper input such as alphabetic characters, decimal points, and commas). Here are some...

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

  • Please help, need to code for this business assignment using c++. Business Expense Reimbursements Calculator Probl...

    Please help, need to code for this business assignment using c++. Business Expense Reimbursements Calculator Problem statement: Business trip is part of the enterprise culture. Suppose a businessperson just completed a business trip for your company. Now, you are tasked to write a program that calculates and displays the total travel expenses, allowable expenses for the trip, and the excess that must be paid by the businessperson, if any The program should prompt the user for the following . The...

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