107k views
2 votes
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 customer's classification code (a character either B, D, or W)

- The number of days the vehicle was rented (an integer)

- The vehicle's odometer reading at the start of the rental period (an integer)

- The vehicle's odometer reading at the end of the rental period (an integer)

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.

- Code 'W' (Weekly) base charge: $350.00 for each week. If the car is kept less than 7 days, then $350.00 is still charged. For rental periods more than 7 days, the base charge is $350 per 7 days and $70 for any days making a fraction of a week(i.e. 9 days means $350 + 2* $70 = $490). Mileage charge: no charge this rental comes with unlimited miles

After calculating the bill, use formatted output to output the total bill with 2 decimal places of precision. Use an appropriate phrase for the output

1 Answer

3 votes

Answer:

The code is given in Python with appropriate tags/quotes for better understanding

Step-by-step explanation:

# python code that will compute and display information for a company which rents vehicles to its customers.

code = raw_input("Enter classification code (a character either B, D, or W): ")

days = int(raw_input("Enter number of days the vehicle was rented: "))

start = int(raw_input("odometer reading at the start of the rental period: "))

end = int(raw_input("odometer reading at the end of the rental period: "))

charge = 0.0

if code == 'B':

charge = 40.00*days + (end-start)*0.25

elif code == 'D':

charge = 60.00*days

if (end -start)/days > 100:

charge = charge + 0.25*((end-start)/days-100)

elif code == 'W':

if days > 7:

charge = charge + (days/7)*350

days = days%7

charge = charge + (days)*70

else:

charge = 350

else:

print "Invalid code"

print "Total charge: $" ,charge

'''

output:

Enter classification code (a character either B, D, or W): W

Enter number of days the vehicle was rented: 23

odometer reading at the start of the rental period: 2

odometer reading at the end of the rental period: 2

Total charge: $ 1190

'''

User Johnsy
by
7.4k points