Exercise 2 – Car Rental Problem DescriptionA car rental company in Amman provide 3 options for customers: o Budget rent: base charge is 14.00 JD for each day and charge 0.25 JD for each KM driven o Daily rent : base charge: 20.00 JD for each day and no charge if the average number of KM driven per day is 100 KM or less; otherwise, charge 0.25 JD for each KM driven above the 100 KM per day limit.o Weekly ret: base charge: 80.00 JD for each week (or fraction of a week) and no charge if the average number of KM driven per week is 900 KM or less; 100.00 JD per week if the average number of KM driven per week exceeds 900 KM but does not exceed 1500 KM; otherwise, 120.00 JD per week plus 0.25 JD for each KM driven above the 1500 KM per week limit.Write and run a python program that repeatedly performs the following:• Displays a menu of options for the user to select from and input one of four letterso B -Budgeto D- Dailyo W- Weeklyo Q – Exit the program• The program askes the user to input a. the number of days the car was rented (any part of the day is considered a full day)b. the car's odometer reading at the start of the rental period (an integer)c. the car's odometer reading at the end of the rental period (an integer)• Use a function named kmCalculator that takes 2 arguments: the car's odometer reading at the start of the rental period and the car's odometer reading at the end of the rental period. The function kmCalculator returns the number of KM driven by the customer during the rental period.• Use a function named billCalculator that takes as arguments the rental’s type, number of days in the rental period, and number of kilometers driven. The function billCalculator returns the amount of money that the customer will be billed• The program (i.e. the main function) Should properly printo the number of KM driven by the customer during the rental period.o the amount of money that the customer will be billed• When an invalid option code is detected, the program will display an error message, and the possible codes then read the code again until a valid code is used. The program will also check the number of days is grater than 0.• Add your name, your University ID number and section number as a comment at the beginning of this program.Sample OutputWelcome to Car Rent Select one of the following options: B -Budget car rent D- Daily car rent W- Weekly car rent Q – Exit the program What is your choice? d How many days(should be grater than 0)?1 What is the car's odometer reading at the start of the rental period (should be grater than or equal to 0) ? 91234 What is the car's odometer reading at the end of the rental period (should be grater than the reading at the start of the rental period)?91400 The number of KM driven is 166 The bill amount is 36. Select one of the following options: B -Budget car rent D- Daily car rent W- Weekly car rent Q – Exit the program What is your choice? ASelect one of the following options: B -Budget car rent D- Daily car rent W- Weekly car rent Q – Exit the program What is your choice? NSelect one of the following options: B -Budget car rent D- Daily car rent W- Weekly car rent Q – Exit the program What is your choice? q Thank you for using the Car Rent System
Exercise 2 – Car Rental
Problem Description
A car rental company in Amman provide 3 options for customers:
o Budget rent: base charge is 14.00 JD for each day and charge 0.25 JD for each KM driven
o Daily rent : base charge: 20.00 JD for each day and no charge if the average number of KM driven per day is 100 KM or less; otherwise, charge 0.25 JD for each KM driven above the 100 KM per day limit.
o Weekly ret: base charge: 80.00 JD for each week (or fraction of a week) and no charge if the average number of KM driven per week is 900 KM or less; 100.00 JD per week if the average number of KM driven per week exceeds 900 KM but does not exceed 1500 KM; otherwise, 120.00 JD per week plus 0.25 JD for each KM driven above the 1500 KM per week limit.
Write and run a python program that repeatedly performs the following:
• Displays a menu of options for the user to select from and input one of four letters
o B -Budget
o D- Daily
o W- Weekly
o Q – Exit the program
• The program askes the user to input
a. the number of days the car was rented (any part of the day is considered a full day)
b. the car's odometer reading at the start of the rental period (an integer)
c. the car's odometer reading at the end of the rental period (an integer)
• Use a function named kmCalculator that takes 2 arguments: the car's odometer reading at the start of the rental period and the car's odometer reading at the end of the rental period. The function kmCalculator returns the number of KM driven by the customer during the rental period.
• Use a function named billCalculator that takes as arguments the rental’s type, number of days in the rental period, and number of kilometers driven. The function billCalculator returns the amount of money that the customer will be billed
• The program (i.e. the main function) Should properly print
o the number of KM driven by the customer during the rental period.
o the amount of money that the customer will be billed
• When an invalid option code is detected, the program will display an error message, and the possible codes then read the code again until a valid code is used. The program will also check the number of days is grater than 0.
• Add your name, your University ID number and section number as a comment at the beginning of this program.
Sample Output
Welcome to Car Rent
Select one of the following options:
B -Budget car rent
D- Daily car rent
W- Weekly car rent
Q – Exit the program
What is your choice? d
How many days(should be grater than 0)?1
What is the car's odometer reading at the start of the rental period (should be grater than or equal to 0) ? 91234
What is the car's odometer reading at the end of the rental period (should be grater than the reading at the start of the rental period)?91400
The number of KM driven is 166
The bill amount is 36. Select one of the following options:
B -Budget car rent
D- Daily car rent
W- Weekly car rent
Q – Exit the program
What is your choice? A
Select one of the following options:
B -Budget car rent
D- Daily car rent
W- Weekly car rent
Q – Exit the program
What is your choice? N
Select one of the following options:
B -Budget car rent
D- Daily car rent
W- Weekly car rent
Q – Exit the program
What is your choice? q
Thank you for using the Car Rent System
Exercise 2 – Car Rental Problem DescriptionA car rental company in Amman provide 3 options for customers: o Budget rent:
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am