data编程代写、代做c/c++程序语言
Introduction to
Software
Engineering and
Programming
Coursework 2
Jing Wang
THE UNIVERSITY OF NOTTINGHAM NINGBO CHINA C Program Requirements
Develop a C program as the real-time inventory system for a newly opened supermarket. The
program should complete the 3 tasks below.
Task 1. Before the supermarket is open to all the customers for the first time, build the inventory
for all the products. This inventory shall be saved as a Text file (with a file extension of .txt) on
the computer, named as Inventory.txt. The supermarket staff (user of this program) will manually
input the information of each product with the following requirements:
1.1. Product name. The product name shall not include spaces (assume the user will not
input spaces), for example, BottledWater, FlatShoes. The number of characters included
in the name shall be no more than 20. If the entered string is longer than 20 characters,
just save the first 20 characters as the product name and ignore the rest characters. No need
to check if there is duplicate name in the inventory.
1.2. Product code. It is a 4-digit number, and shall be unique for each product. The product
code is numbered based on the entry sequence, i.e. product code for the 1
st
entry is 0001,
and 0002 for the 2
nd
entry, etc. The code shall be generated automatically by the program.
No more than 1000 products are allowed to input. When receiving 1000 product
information, finish entry and display a proper message to the user.
1.3. Unit Price. The unit price of each product shall be of data type “float”, and shall be less
than 1000 RMB. If the unit price is higher than or equal to 1000 RMB, display a proper
error message and request the user to input again until a valid input is received.
1.4. Quantity. The quantity of each product shall be of data type “integer” and shall be less
than 100. If the quantity is more than 100, display a proper error message and request the
user to input again until a valid input is received.
1.5. Terminate entry. If there are less than 1000 products, the user can press ctrl+z then press
enter to terminate input to the inventory.
1.6. Full information package for each product. For each product, 4 information should be
saved, i.e. items from step 1.1 to 1.4 (refer to N1).
1.7. User-friendly message. Prompting messages and error messages shall be designed to be
user-friendly.
1.8. Complete all the tasks in Task 1 in an external function.


Now the inventory is done. The supermarket is ready to welcome all the lovely customers. Task 2. For each customer, the products to purchase will be entered to the cashing system one by
one and the customer will received a receipt of all the purchased products by the end, meanwhile,
the inventory system shall be updated on the quantities of the corresponding products. All the tasks
in Task 2 shall be completed in function main(). Detailed requirements are followed.
2.1.Display a welcome message as shown below.
***********************************************
* UNNC-Super *
* Type the code ID *
* Type F to finish *
***********************************************
Note: Information in white color above shall be the same as in your program. The requirement is
the same for all the following white-color messages.
2.2.Show the message below to allow the cashier to enter the product code (assume the product
codes have been attached to the products beforehand). One entry per line.
Product Code:

2.3.For each product code entry, the system will search the inventory and locate the product
name, unit price and remaining quantity. If no match can be found, display the following
error message, and get back to step 2.2.
This product code does not exist! Try again!

2.4.For valid product code, display the product name and unit price to the screen. Design the
displayed information to be user-friendly.
2.5.Show the message below to enter the quantity of the product that the customer purchases.
One entry per line.
Product Quantity:

2.6.If the quantity to purchase is larger than the product’s quantity recorded in inventory,
display the following error message and input the quantity again until a valid input is
received.
Quantity entry is wrong! Check the quantity and enter again:

2.7.Update the product quantity in the inventory. For example, the quantity of BottledWater in
inventory is 90, after the customer purchases 10 of them, the quantity of this product in the inventory is updated to 80, while the information of all other products shall not be changed
(refer to N2).
2.8.The entry process of each product will keep repeating from step 2.2 to step 2.7, until the
cashier types F to finish.
2.9.Once the product entry for this customer finishes, display a receipt that shows a greeting,
the shopping list, and the total cost. The order of the items on the receipt should be in the
same order of the item entry sequence. An example receipt is shown below.
_____________________________________

THANK YOU FOR VISITING UNNC - Super!
_____________________________________
Here is your receipt:

Item Code Ut. Price Quant. Price
Dish 0071 25.00 3 75.00
Beef 0032 45.00 2 90.00
Bowl 0071 25.00 3 75.00
BottledWater 0001 5.00 5 25.00
FlatShoes 0123 268.00 1 268.00
_____________________________________
TOTAL COST: 533.00
Transaction Date: 15:00:00 Wed Nov 20 2024
Note: Information in red color above is presented only for the purpose of format demonstration,
and the information displayed by your program shall follow the same format but with different
content depending on program entry. All the information shall be displayed in the same color as
the default setting of CodeBlocks.
2.10. After printing the receipt, use the following message to allow for the entry of cash.
Cash Received:

2.11. Display the following message to indicate the change from the cash received. If the
cash received is not enough, display a proper error message and get back to step 2.10. Note:
in step 2.10, the cash received is the overall cash received, not the cash increment.
Change Given:

2.12. When the transaction finishes, display the following message. If Y is entered, repeat
steps from 2.1 to 2.12. If N is entered, proceed to Task 3.
Next customer? (Y/N) Now take a break when no customer is here.
Refreshed? Guess so.
Let’s check the inventory to see if any product is short of storage.

Task 3. Check the inventory and find all the products with short storage. Complete this task in the
2
nd
external function. Detailed requirements are followed.
3.1. In the inventory, find all the products with a quantity less than 5. These products shall be
saved in a new file named as Short_RedFlag.txt. The format of information to be saved in
Short_RedFlag.txt shall be the same as in Inventory.txt. Meanwhile, count how many
products are saved in Short_RedFlag.txt.
3.2. In the inventory, find all the products with a quantity more than 4 and less than 15. These
products shall be saved in a new file named as Short_BlueFlag.txt. The format of
information to be saved in Short_BlueFlag.txt shall be the same as in Inventory.txt.
Meanwhile, count how many products are saved in Short_BlueFlag.txt.
3.3. After finish step 3.1 and 3.2, display a message to the output screen as shown below.
Purchase now! There are 10 red-flag storage products.

Add to your To-Do List! There are 22 blue-flag storage products.
Note: Information in red color above is presented only for the purpose of format demonstration,
and the information displayed by your program shall follow the same format but with different
content depending on program entry. All the information shall be displayed in the same color as
the default setting of CodeBlocks.


Everything is done.
Happy Hour Time!

Note
N1. When inputting to the inventory in Task 1, specifying the field width for each information
will be very helpful.
N2. In Task 1, besides the 3 modes introduced at the lecture, there are more modes to open a
file, e.g. “r+”, “w+”, “a+”, “wb”, etc., which were mentioned briefly at the lecture as selfstudy
topics. Learn how to open files in a mode different from the 3 introduced modes in
order to work on this coursework (which is quite straightforward after you figure out how
to use the 3 introduced modes). Plenty of helpful resources are available online, and you
may kick off with this one and this one.
N3. Task 1 and Task 3 are completed in separate external functions.
N4. For coursework submission, the file, Inventory.txt, which is generated and completed in
Task 1, shall be saved and renamed as Inventory_sbm.txt for submission. Therefore, in the
file of Inventory_sbm.txt, the information of all the products before the 1st customer starts
shopping should be included.
N5. The C project and the file Inventory_sbm.txt shall be submitted as one archive file to
Moodle (allowed file extensions are .7z and .zip). An example of the submission file is
shown in the images below, together with the instruction on how to compress a folder.

N6. Comment your program properly and use proper indentation and blank lines to increase
the readability of your program.
N7. Submission deadline for this coursework is 3pm, 11 December 2024. Plan your time in
advance, and avoid last-minute submission.
N8. All C programs will be tested using the CodeBlocks installed on university computers.
Therefore, make sure that your C program runs well on a university computer as you
expected before submitting your work on Moodle.
N9. Messages displayed in green highlights are only for fun, and are not programming tasks.

Marking Scheme
Kindly be reminded that successful compilation and execution of a program doesn’t mean a full
mark for each task. The algorithm, efficiency, memory will be assessed as well.


热门主题

课程名

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
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图