Starting from:
$30

$24

Assignment 1 Solution




Learning Outcome:

By completing this assignment, you will gain skills relating to




basic programming constructs, expressions and decisions,




getting input from user, validating input,




algorithm development and testing.




Task:




In this assignment, you will write a complete program in Python that computes rental costs for a car rental company. Your program is expected to prompt the user for input and validate it before computing the results. Your program should make use of expressions, decisions and basic input/output in Python.




Functional Specifications:




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. The program will prompt the user to enter the following items for a given customer (in the specified order):



The customer’s name (a string)
The customer's classification code (a character).
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).
It will then process that customer information and display the results.

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 kilometers driven.



The program will recognize both upper case and lower case letters for the classification codes; the codes and related information are as follows:



Code 'B' (budget)

base charge: $20.00 for each day,



kilometers driven charge: $0.30 for each kilometer driven.



Code 'D' (daily)

base charge: $50.00 for each day,
kilometers driven charge: no charge if the average number of kilometers driven per day is 100 kilometers or less; otherwise, $0.30 for each kilometer driven above the 100 kilometer per day limit.



Code 'W' (weekly)



base charge: $200.00 for each week or fraction of a week (i.e., each fraction of a week is treated as a week, for example 8 days is treated as 2 weeks),



kilometers driven charge:



There is no additional charge if the average number of kilometers driven per week is 1000 kilometers or less;




If the average number of kilometers driven per week exceeds 1000 kilometers but does not exceed 2000 kilometers, then there is an additional $50.00 charge per week;




If the average number of kilometers driven per week exceeds the 2000 kilometer per week limit, then there is an additional $100.00 charge per week plus $0.30 for each kilometer driven over the 2000 kilometer per week average for each week.







The program will compute the number of kilometers driven by the customer during the rental period.



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

The customer’s name,



The customer's classification code,
The number of days the vehicle was rented,
The vehicle's odometer reading at the start of the rental period,
The vehicle's odometer reading at the end of the rental period,



The number of kilometers driven during the rental period,
The amount of money billed to the customer for the rental period,



All output should be appropriately labeled and formatted. The amount of money billed should be displayed with a dollar sign and will be rounded to two fractional digits (for example, $125.99 or $43.87).




The program should also detect and report invalid classification codes. When an invalid classification code is detected, the program will display an error message as well as the invalid code and customer’s name. After displaying this information the program should end.



The program will assume that all other user inputs are valid and correct. That is, the program will not check the number of days or odometer readings for validity






Non-functional Specifications:




Include brief comments in your code identifying yourself, describing the program, and describing key portions of the code.Assignments are to be done individually and must be your own work. Software may be used to detect cheating.



Use Python coding conventions and good programming techniques, for example:

Meaningful variable names
Conventions for naming variables and constants



Use of constants where appropriate
Readability: indentation, white space, consistency



The name of the file you submit should be your UWO userid_Assign1.py. For instance, my assignment would be oola_Assign1.py. Make sure you attach your python file to your assignment; DO NOT put the code inline in the textbox.




Make sure that you develop your code with Python 3.5 as the interpreter. TAs will not endeavor to fix code that uses earlier versions of Python.




What You Will Be Marked On:

Functional specifications:



Does the program behave according to specifications? Does the program handle invalid input?




Is the output according to specifications?




Non-functional specifications: as described above
Assignment submission: via OWL assignment submission

More products