首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
COMP1117B代做、代写Python编程设计
项目预算:
开发周期:
发布时间:
要求地区:
The University of Hong Kong
COMP1117B Computer Programming
Assignment 4
Due date: Apr 29, 2024, 23:59
Reminder
This assignment involves a lot of console input/output. You are reminded that the VPL
system on HKU Moodle evaluates your program with a full score under the condition that
your program output is the EXACT MATCH of the expected output. In other words, any
additional or missing space character, newline character, etc., will be treated as errors
during the evaluation of your program. Also, you are suggested to design more test cases on
your own for testing your program.
You are allowed to use any Python built-in functions. However, you cannot import modules other
than those mentioned in this assignment.
Objective
Your client, XYZ Company, provides car rental services. For this assignment, you are to develop
a rental system for the company’s internal management of rental transactions. The system should
allow managers to analyze rental data and query whether a specific car is available for a new
rental.
The techniques we learned in the previous chapters, such as Files, Sets, Dictionaries, and Tuples,
would be useful for handling this assignment.
Import Data from File
The company’s rental transaction data is stored in a text (.txt) file. Each row represents a rental
transaction with the following fields separated by a single space:
• Car ID (e.g., 01)
• Rental Start Date (e.g., 2024-04-15)
• Customer ID (e.g., 001)
• Rental Fee per Day (integer)
• Rental Days (e.g., 5)
For example, a text file (data.txt) with five records has the following content:
01 2024-04-15 001 50 1
08 2024-04-25 002 45 6
01 2024-05-05 001 50 10
01 2024-05-20 003 60 30
15 2024-05-20 002 45 8
2 IN 9
The program should be able to read the file by specifying the name of the data file.
Below is the input and output for loading the file data when the program starts (Text in
bold is user input):
Transaction records to import:
data.txt
Imported 5 transaction(s) to the system.
Notes:
• The program should automatically assign transaction IDs for each line of the transaction
data (the data.txt file). The transaction ID starts with 1 and then increases by 1 for each
row of the records. For example, the assigned ID of the first line of the transaction data
(01 2024-04-15 001 50 1) is 1, then the next line transaction’s ID is 2, and so on
and so forth.
• The program has not been terminated yet.
Hints:
• You might use a dictionary to store the transaction records after reading the .txt file.
• You might use split() to split a string into a list.
Main Menu
After importing course sessions from the file, the system enters the main menu and
reads a user command repeatedly until the user inputs “Exit”. You should implement the
following SIX commands for the system.
The example data.txt file mentioned in the previous section is used for the following cases.
1. Exit
By inputting the command Exit, the program prints "Thank you for using the Car Rental
System. Goodbye!" and terminates.
Transaction records to import:
data.txt
Imported 5 transaction(s) to the system.
Exit
Thank you for using the Car Rental System. Goodbye!
3 IN 9
2. CarTransaction
By inputting the command CarTransaction, the system lists all cars in the rental
transaction records based on the imported data. Prints the car ID and the number of rental
transactions for each car. Sorts the records in ascending order by the Car ID.
Transaction records to import:
data.txt
Imported 5 transaction(s) to the system.
CarTransaction
Here is the rental transaction for the cars:
The Car 01 has been rented 3 time(s).
The Car 08 has been rented 1 time(s).
The Car 15 has been rented 1 time(s).
3. CarHistory |
This command can list the transaction summary of the specific Car ID in the format
shown in the example below. The records should be sorted by the total number of
rental days in descending order. You can assume that no records have the same total
number of rental days.
Total number of rental days is the sum of the rental days made by the
on
.
The records by the same customer should be merged. For example, assuming Customer
001 made two transactions on Car 01 with rental days of 1 and 10 days, respectively, the
total number of rental days for Customer 001 on Car 01 should be 11.
Transaction records to import:
data.txt
Imported 5 transaction(s) to the system.
CarHistory | 01
Here is the rental summary for the Car 01:
Customer 003 30 day(s)
Customer 001 11 day(s)
4. RentalPeriodAnalysis |
|
This command lists all rental transactions’ starting date time within a specific period
(includes the inputted start and end dates). Display the following information for that period
(sort the records in ascending order by the transaction ID):
4 IN 9
Transaction records to import:
data.txt
Imported 5 transaction(s) to the system.
RentalPeriodAnalysis | 2024-04-15 | 2024-04-25
Rental summary record(s) from April 15, 2024 to April 25, 2024:
01 2024-04-15 001 50 1
08 2024-04-25 002 45 6
5. TopSpendCustomers |
This command determines the top customers based on their total spend amount across all
rental transactions. The
parameter specifies the maximum number of top
customers to display.
Display the customer ID, total spend amount, and the number of
transactions for each top customer. Sort the records in descending order by total
spend amount. You can assume that no records have the same total spend
amount in the data.
Transaction records to import:
data.txt
Imported 5 transaction(s) to the system.
TopSpendCustomers | 2
Here are the top 2 customer(s) by total spend amount:
Customer 003 has spent $1800 on 1 transaction(s).
Customer 002 has spent $630 on 2 transaction(s).
6. CheckCarAvailability |
|
|
This command allows the manager to check if a specific car is available or occupied during
a given rental period. If the car was occupied for any part of the date range, even just a
single day, then the entire period is considered occupied. The
parameter
represents the car's ID to check. The
parameter represents the
rental start date to check for availability. The
parameter represents
the number of days lasting for rental.
If the car is not found in the rental transaction records, display the message “The car is not
found.” indicating that the car is not in the previous transaction records.
If the car is found, check whether it is available or occupied based on the rental transaction
records and the attempted rental period.
5 IN 9
Print the message “The Car
is available in this period.” indicates the car is available.
If the car is occupied, print the message “The Car
is occupied in this period.” Then,
print all the occupied days by line (see the example below).
Example 1 Transaction records to import:
data.txt
Imported 5 transaction(s) to the system.
CheckCarAvailability | 01 | 2024-04-20 | 1
The Car 01 is available in this period.
Example 2 Transaction records to import:
data.txt
Imported 5 transaction(s) to the system.
CheckCarAvailability | 01 | 2024-05-08 | 6
The Car 01 is occupied in this period.
The occupied date(s):
2024-05-08
2024-05-09
2024-05-10
2024-05-11
2024-05-12
2024-05-13
Example 3 Transaction records to import:
data.txt
Imported 5 transaction(s) to the system.
CheckCarAvailability | 20 | 2024-05-10 | 1
The car is not found.
Tips:
• The datetime module in Python contains useful functions for handling dates and times.
To use these functions, you need to import the datetime module at the beginning of
your code.
Example: from datetime import datetime, timedelta
• Parsing Dates:
You can use the datetime.strptime() function to parse a string representation of a date into
a datetime value.
Example: date = datetime.strptime("2024-04-15", "%Y-%m-%d")
6 IN 9
• The previous tip, “parsing dates,” is the prerequisite for the functionality of the tips below
on “comparing dates,” “formatting dates,” and “date arithmetic.”
• Comparing Dates:
You can directly compare datetime values using comparison operators
like <, <=, >, >=, ==, and !=.
Example: if start_date <= date <= end_date:
• Formatting Dates:
You can use the strftime() method of a datetime value to format it as a string.
Example:
date = datetime.strptime("2024-04-15", "%Y-%m-%d")
formatted_date = date.strftime("%B %d, %Y") will format the date as
"April 15, 2024".
• Date Arithmetic:
You can perform date arithmetic using the timedelta class from
the datetime module.
Example: new_date = date + timedelta(days=5) will add 5 days to the
variable date.
• We provide the program structure for this assignment on the next page. You can include
these functions in your program and start working from them, or you can also choose to
design your program all from scratch.
7 IN 9
8 IN 9
Implementation Notes
1. You can assume that user inputs and the input file are always valid. That means you
don’t need to consider cases that have not been mentioned in the requirement.
2. Do not print space character at the end of output lines.
3. The input file is used to import data only. Do not modify the input file.
4. You are allowed to use any Python built-in functions. However, you cannot import modules other
than those mentioned in this assignment.
Submission
Submit your program electronically using the Moodle system to Assignment 4 under the
Assignment section. Late submissions will not be accepted.
• Your program must follow the format of the sample input and output strictly.
• The sample input file (data.txt) is included in the evaluation environment for test cases
evaluation. You do not need to upload them.
• You should only submit source code (*.py)
• We will grade your program with another set of input files and test cases (Not limited
to the sample input file data.txt and test cases). That means we will change the input
file and test cases on Moodle after the submission deadline.
Policy on Plagiarism according to the General Office of CS Department
Plagiarism is a very serious academic offence. Students should understand what constitutes
plagiarism, the consequences of committing an offence of plagiarism, and how to avoid it.
As defined in the University's Regulations Governing Conduct at Examinations, plagiarism is
"the unacknowledged use, as one's own, of work of another person, whether or not such
work has been published.", or put it simply, plagiarism is copying (including paraphrasing)
the work of another person (including an idea or argument) without proper
acknowledgement.
In case of queries on plagiarism, students are strongly advised to refer to "What is
Plagiarism?" at https://tl.hku.hk/plagiarism/
If a student commits plagiarism, with evidence after investigation, no matter whether the
student concerned admits or not, a penalty will be imposed:
First Attempt: if the student commits plagiarism (in an assignment/test of a CS course) for
the first time in his/her entire course of study, the student shall be warned in writing and
receive zero mark for the whole assignment or the whole test; if the student does not agree,
s/he can appeal to the BEng(CompSc) Programme Director within a week;
9 IN 9
Subsequent Attempt: if the student commits plagiarism more than once in higher course of
study, the case shall be referred to the Programme Director for consideration. The
Programme Director shall investigate the case and consider referring it to the University
Disciplinary Committee, which may impose any of the following penalties: a published
reprimand, suspension of study for a period of time, fine, or expulsion from the University.
Both the student who copies other's work and the student who offers his/her work for
copying shall be penalized.
Teachers should report plagiarism cases to the General Office for records and the issuing of
warning letters.
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!