Question

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 vehicle's odometer reading at the start of the rental period (a number)

d. The vehicle's odometer reading at the end of the rental period (a number)

It will then process that customer information and display the results. It will halt when the

user enters “Q”(or “q”) instead of a classification code.

2. The program will compute the amount of money that the customer will be billed, based

on the customer’s classification code, number of days in the rental period, and number of

miles driven.The program will recognize both upper case and lower case letters for the

classification codes. Code 'B' (budget)

base charge: $40.00 for each day

mileage charge: $0.25 for each mile driven

Code 'D' (daily)

base charge: $60.00 for each day

mileage charge: no charge if the average number of miles driven per day is 100

miles or less; otherwise, $0.25 for each mile driven above the 100 mile per day limit.

The amount billed to the customer is the sum of the base charge and the mileage charge.

3. For each customer, the program will display a summary with the following information:

a. The customer's classification code

b. The number of days the vehicle was rented

c. The vehicle's odometer reading at the start of the rental period

d. The vehicle's odometer reading at the end of the rental period

e. The number of miles driven during the rental period

f. The amount of money billed to the customer for the rental period

4. When an invalid classification code is detected, the program will display an error

message.

Note:

Use the built in input function to take input from the user. For example, the following code

will take a string from the terminal and assign that to the variable name.

name = input("Please input your name: ")

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

Please refer to screenshots

Code

Output

Code to copy


# function to calculate bill
def calculate_amount(code, days, miles):
    # if classification code is b or B
    if code == 'b' or code == 'B':
        total = 40.00 * days # calculating for days rented
        total += miles * 0.25 # adding for miles driven
        return total
  
    # if classification code is d or D
    if code == 'd' or code == 'D':
        total = 60.00 * days
        avg = miles / days # calculating average
        if avg > 100:
            # if average miles per day driven is more than 100
            total += 0.25 * (miles - (100 * days)) # calculating extra bill after average miles driven
          
        return total

# function to display mile
def display_bill(code, days, start, end):
    miles = end - start # calculating total miles driven
    amount = calculate_amount(code, days, miles) # calculating bill
    print("\nBill Summary\n")
    print("Classification code:", code)
    print("Number of days for vehicle rented:", days)
    print("Vehicle odometer's reading at the start of rental period:", start)
    print("Vehicle odometer's reading at the end of rental period:", end)
    print("Number of miles driven during the rental period:", miles)
    print("Amount of money billed to the customer for the rental period:", amount)
    print(" ")


# main function
def main():
    valid_codes = ['q', 'Q', 'b', 'B', 'd', 'D'] # valid code
    while True:
        head = "Enter classification code: "
        while True:
            code = input(head)
            if code in valid_codes: # if code is valid
                break
            head = "Please enter valid classification code: "
      
        # if code id q or Q
        if code == 'q' or code == 'Q':
            break
        # taking input
        days = input("Number of days for vehicle is rented: ")
        days = int(days)
      
        start = input("Enter vehicle's odometer reading at the start of the rental period: ")
        start = int(start)
      
        end = input("Enter vehicle's odometer reading at the end of the rental period: ")
        end = int(end)
      
        display_bill(code, days, start, end) # displaying bill
      
main()

Add a comment
Know the answer?
Add Answer to:
in Python The program will compute and display information for a company which rents vehicles to...
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
  • 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...

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

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

  • in python create a program to display the cost of renting a smart car. the user...

    in python create a program to display the cost of renting a smart car. the user must be able to enter the number of days he/she rents the cat and the number of miles driven. use constants for the flat rate per day and the flat rate per mile. the program will display the flat rate per day, flat rate per mile, and the total cost of the car rental.

  • Write a Python program that does the following: Obtains the following input from a user: Mileage...

    Write a Python program that does the following: Obtains the following input from a user: Mileage at beginning of measurement period Mileage at end of measurement period Gallons of fuel consumed Calculates and displays: Miles driven Miles per gallon Kilometers driven Liters of fuel consumed Kilometers per liter Incorporate some Selection structure logic into it: If a vehicle gets less than 15 miles per gallon, display the message:       "Your vehicle has criminally low fuel efficiency." If it gets 15...

  • Write a Python program that does the following: Obtains the following input from a user: Mileage...

    Write a Python program that does the following: Obtains the following input from a user: Mileage at beginning of measurement period Mileage at end of measurement period Gallons of fuel consumed Calculates and displays: Miles driven Miles per gallon Kilometers driven Liters of fuel consumed Kilometers per liter Also incorporate some selection structure logic into it. If a vehicle gets less than 15 miles per gallon, display the message:       "Your vehicle has criminally low fuel efficiency." If it gets...

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

  • 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 need trying to figure out how I can make create a code in Python with this exercise for I am having trouble doing so. Miles Per Gallon Calculator Write a GUI program that calculates a car's gas...

    I need trying to figure out how I can make create a code in Python with this exercise for I am having trouble doing so. Miles Per Gallon Calculator Write a GUI program that calculates a car's gas mileage. The program's window should have Entry widgets that let the user enter the number of gallons of gas the car holds, and the number of miles it can be driven on a full tank. When a Calculate MPG button is clicked,...

  • 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
Active Questions
ADVERTISEMENT