11/20/2024Introduction to
SoftwareEngineering andProgrammingCoursework 2rogram Requirements Develop a C program as the real-time inventory system for a newly opened supermarket. Theprogram should complete the 3 tasks below.
Task 1. Before the supermarket is open to all the customers for the first time, build the inventoryfor all the products. This inventory shall be saved as a Text file (with a fileextension of .txt) onthe computer, named as Inventory.txt. The supermarket staff (user of this program) will manuallyinput 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 includedin 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 needto 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 productcode is numbered based on the entry sequence, i.e. product code for the 1st entry is 0001,and 0002 for the 2nd entry, etc. The code shall be generated automatically by he program.No more than 1000 products are allowed to input. When receiving 1000 productinformation, 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 RMBdisplaya propererror 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 messageand request theuser 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 beuser-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 thecashing system one byone 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 productcodes 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 productname, unit price and remaining quantity. If no match can be found, display the followingerror 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 thedisplayed 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 isreceived.
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 ininventory is 90, after the customer purchases 10 of them, the quantity of thisproduct 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
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 thesame order of the item entry sequence. An example receipt is shown below._____________________________________ 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 fromthe 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代写Aeal-time inventory System finishes, display the following message. If Y is entered, repeatsteps 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 the2 ndexternal function. Detailed requirements are followed.3.1. In the inventory, find all the products with a quantity less than 5. These products shall besaved in a new file named as Short_RedFlag.txt. The format of information to be saved inhort_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. Theseproducts shall be saved in a new file named as Short_BlueFlag.txt. Theformat ofinformation 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.Purchasenow! 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 displayein 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 informationwill be very helpful.N2. In Task 1, besides the 3 modes introduced at the lecture, there are more modes to open afile, 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 inorder to work on this coursework (which is quite straightforward after you figureout howto use the 3 introduced modes). Plenty of helpful resources are available online, and youmay 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 inTask 1, shall be saved and renamed as Inventory_sbm.txt for submission. Therefore, in thefile of Inventory_sbm.txt, the information of all the products before the 1st customer startsshopping should be included.N5. The C project and the file Inventory_sbm.txt shall be submitted as one archive file toMoodle (allowed file extensions are .7z and .zip). An example of the submission file isshown 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 increasethe readability of your program.N7. Submission deadline for this coursework is 3pm, 11 December 2024. Plan your time inadvance, 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 youexpected 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 fullmark for each task. The algorithm, efficiency, memory will be assessed as well.
标签:product,shall,System,Aeal,products,inventory,entry,message From: https://www.cnblogs.com/BUS001/p/18593380