We have all gone shopping before, whether for groceries, computer gadgets or milk and eggs. We… 1 answer below »

We have all gone shopping before, whether for groceries, computer gadgets or milk and eggs. We expect that the cashier (human or automatic) identifies and enters a code for each item we purchase and after entering all the items a transaction receipt is issued, we pay and go home. We may not have direct experience of running the store, but it is not hard to imagine that the transaction data is stored in a file. At the end of the day, that file, which contains all the day’s transactions for the number of customers who made purchases, can be processed to obtain such things as the numbers of items sold (by individual item, or by category such as meat or chewing gum) and the amount of revenue (i.e. money) obtained. This is illustrated in Figure 1. Your task is to design and write a complete C language program to carry out the job described above, in general terms. The details of this task are stated in the following paragraphs. Note that several examples are provided on following pages in order to explain and guide you in understanding your task and how to approach it. This problem is designed to examine your understanding of file processing, and dynamic memory allocation and linked list concepts and techniques, in addition to other programming techniques. Details: A grocery store needs a computer program to help keep track of inventory and price data. The program must work by processing all the customer transactions gathered during each day. At the beginning of the day the program logic is started and all initialization steps are carried out before processing any customers. The initialization steps require inputting data from two files that provide numbers and name strings for various categories of goods that are sold by the grocery store. This data is referenced throughout the program. You should review the example data and notes in Use-Case 1 (Input File Name: CategoryName.dat) and Use-Case 2 (Input File Name: CodeNamePrice.dat). For each customer, the cashier processes items in the order received – you might recall how each item is scanned for a barcode and the number of items of the same kind is entered. After the last item is processed for a given customer, the cashier triggers generation of a transaction receipt. This receipt is sorted by an item code, and states the name, price/item, number of items and total cost for that item (or group of items if more than one) and which, in summary, then lists the total number of items of all types (or codes) purchased and the total purchase price for the complete transaction. Usually this would be done using a cash register, but for this problem we simulate data entry through an input file and output using standard output. You should review the example data and notes in Use-Case 3 (Input File Name: DailyTransactions.dat). Note that the order of items processed is not sorted; as it is inputted, it must be sorted by the item code, preparing for the next step. After the final record of items input, a Code value of 000 indicates the end of the transaction listing. For every customer, the transaction receipt generated looks like the output shown in Use-Case 4. Each line consists of various fields, each of fixed size, following a fixed format spacing shown in Use-Case 4. Each line consists of a Code (3 digit number from 100 to 888), Item Name string (16 characters, including blanks), Price per item, number of items sold, and the total item cost (Price x number of items sold). This output is just sent to the standard device. As each customer item is inputted, it is necessary to update the values of total number of that particular item and the total revenue, or money earned, respectively. This is done using the item code as a key. You should review the example data and notes in Use-Case 1 and Use-Case 5. Since not all item code values are assigned names and prices, it is not suitable to use an array-based solution. Rather, a set of linked lists is preferred as they are straightforward to set up and manage and they provide better access performance to find data. Thus, it is recommended that you use an array of structures, with each array element storing Page 3 of 12 data for a Category, noting that mapping a Category Code to a subscript is easy, just divide by 100 and subtract 1 – 100 maps to 0, 200 maps to 1 and so on up to 800 maps to 7. Within each array element structure you can define fields for total items sold and total money obtained, along with a root pointer to a linked list of individual items sold. This is partially illustrated in Figure 2. At the end of the day, once all customer data has been processed, two reports are generated and one file is produced. You should review the example data and notes in Use-Case 5 and Use-Case 6. Below is a pseudo-coded algorithm that captures many, but not all, of the logical steps necessary to completely solve the problem. You may use this as a guide, but you are not required to do so. Within the algorithm there are comments that reference Use-Cases and file names. These are discussed in the context of detailed example data and formatting in following pages of this document. Start: // See Use-Case 1. Input File Name: CategoryName.dat // See Use-Case 2. Input File Name: CodeNamePrice.dat Initialize variables, data structures, using data from designated input files // See Use-Case 3. Input File Name: DailyTransactions.dat Open input file handle for customer transactions Initialize structures and root pointers for linked lists. // See Use-Case 3. Input File Name: DailyTransactions.dat While more data exists do Process customer transaction data Sort customer transaction data by item code // See Use-Case 4. Generate customer receipt sorted by item code, with totals // See Use-Case 5. Update category and item code sales data totals End while Close non-required file handles // See Use-Case 5. Outputs sent to: stdout and to: InventoryX00.dat Open output file handles for inventory data file and summary reports. Generate and output reports and inventory data to files. Close non-required file handles // See Use-Case 6. Outputs sent to: stdout Output summary report. // make sure all dynamic memory allocations have been de-allocated :End Page 4 of 12 Evaluation: The evaluation of your work is necessarily subjective. A fair evaluation is one that considers the work submitted and assigns grades based on how relevant, complete and accurate the stated solution is. The following points will be considered. Note that the marks indicated must be taken as rough indicators, or guidelines only, for the relative weights for particular aspects of your solution strategy; the actual marking procedure may differ depending on the approach taken by individual students. Keep in mind that there are many solution strategies that may arrive at the same results. Declare variables, data structures, user defined types, file handles, etc. [ 5 marks ] Initialize variables, data structures, user defined types, file handles, etc. [ 5 marks ] Declare function prototypes [ 5 marks ] Define functions [ 15 marks ] Process each customer list [ 15 marks ] Generate customer receipt sorted by item code, with totals [ 5 marks ] Update inventory data [ 15 marks ] Generate and output reports and inventory data to files. [ 15 marks ] Close non-required file handles [ 5 marks ] Output summary report. [ 10 marks ] Deallocate all dynamic memory allocations [ 5 marks ] [ TOTAL: 100 marks ] Page 5 of 12 Declaration of Personal Academic Integrity – COMP 1410 – Winter 2020 As a consequence of the current COVID-19 health crisis and disruption of normal academic procedures, the University Senate, and President, regular Final Examinations have been cancelled and course instructors have been tasked with developing an alternative approach to the final evaluation requirement. For the course COMP 1410, this requirement involves answering a set of questions and submitting answers that are arrived at independently by each student. Thus, the final requirement is essentially an open-book, take-home Final Examination. Academic integrity is fundamental to learning and scholarship at the University of Windsor. Academic honesty and responsibility are fundamental to good scholarship and learning. As members of this academic community, you have a responsibility to conduct yourself in accordance with these expectations. The final requirement for individual evaluation in this course is designed to give you an opportunity to demonstrate what you have learned about important skills and concepts presented in this course as part of the stated syllabus. Completing and submitting the exam answers independently, without any help from other persons or sources, demands the highest standards of academic integrity and honesty on the part of each, and every, student. It is the responsibility of each student to read and be aware of the meaning of academic integrity at the University of Windsor. There are two documents, approved by the University Senate, that apply and describe the kinds of conduct and sanctions; these can be found at the link: http://www.uwindsor.ca/academic-integrity/306/student-resources. There are two parts – the Student Code of Conduct and the Bylaw 31: Academic Integrity. This examination necessarily allows for use of books and online resources. However, it is assumed that students will work independently – it is strictly forbidden to collaborate or copy from other students or any other person. Any such collaboration or copying is considered a violation of the code of conduct and unethical behaviour. When you have completed your Final Examination answers, and are ready to submit your work, you must complete and sign this declaration in the spaces provided below, attesting to your own honesty in completing the examination on your own and that you understand the meaning of academic integrity in the context of this Final Examination. If you are submitting a complete C language program file, you may copy and paste this document into your file and complete the signature portion using your student ID (which should be private and unique). PRINT FULL NAME: _______________________________________________ SIGNATURE: _______________________________________________ If you have any questions about what is, or what is not, permitted in this course, please do not hesitate to contact your instructor. Page 6 of 12 Use-Case 1: CATEGORY NAMES Input File Name: CategoryName.dat The following line is not input, only for information Code Code Category Name 100 Food Vegetables 200 Food Meats 300 Food Breads Grains 400 Food Frozen 500 Food Canned 600 Toiletries 700 Cleaning Supplies 800 Other Page 7 of 12 Use-Case 2: CODE NAMES AND PRICES Input File Name: CodeNamePrice.dat The following lines are not input, rather guides for input spacing 12345678901234567890123456789012345 Code Item Name Item Price (Names of data fields) 101 Broccoli 1.89 104 Cauliflower 2.53 115 Lentils 5.63 120 Celery 0.59 175 Zucchini Green 2.24 176 Zucchini Purple 3.00 201 Anchovy 1.37 230 Chicken Breast 10.78 231 Chicken Leg 8.22 264 Beef Steak 30.20 402 Peas 5.00 405 Corn Kernels 4.00 428 Water Chestnuts 5.65 501 Beans Green 2.78 509 Beans Brown 2.24 585 Chicken Broth 1.89 605 Toothpaste 8.00 610 Hand Soap Bars 7.30 611 Hand Soap Foam 6.53 704 Dish Soap 7.50 710 Detergent 24.12 802 Chewing gum 2.00 805 Licorice 3.50 831 Batteries AA 12.47 840 Cutlery Set 26.00 843 Dishes 49.99 870 Towel Set 54.67 875 Sheets 67.00 Notes: – This data is intended as an example only. – Some possible Code numbers may not be assigned, hence there is no Item Name or Item Price. – Additional data may be provided in the CodeNamePrice.dat file, beyond what is shown in this example. It is also possible that less data may be provided. Page 8 of 12 Use-Case 3: INPUT DATA FORMAT Input File Name: DailyTransactions.dat The following lines are not input, rather guides for input spacing 123456789012345678901234567890123456789012345 Code NumItem (Names of data fields) 802 5 120 2 264 1 585 2 115 2 605 1 704 1 201 1 230 2 402 1 231 3 509 4 710 1 843 1 000 Notes: – This is an example of file input for only one customer’s transactions. Some shopping lists consist of only 1 item type, while others may be very lengthy. – Although not shown in this example, each customer’s data is assigned a Customer Receipt number (# 98 in this case – see Use-Case 4). – Each customer’s list is terminated (i.e. delimited) by a Code value of 000 (or just 0). – The formatting of numeric input values is left to each programmer to define and code. A final code of 000 (or just 0) denotes the end of the customer purchase list. Page 9 of 12 Use-Case 4: TYPICAL CUSTOMER RECEIPT FORMAT Output sent to: stdout The following lines are not input, rather guides for report spacing 123456789012345678901234567890123456789012345678901234567890 Customer Receipt # 98 Code Item Name Price NumItem TotSale 115 Lentils 5.63 2 11.26 120 Celery 0.59 2 1.18 201 Anchovy 1.37 1 1.37 230 Chicken Breast 10.78 2 21.56 231 Chicken Leg 8.22 3 24.66 264 Beef Steak 30.20 1 30.20 402 Peas 5.00 1 5.00 509 Beans Brown 2.24 4 8.96 585 Chicken Broth 1.89 2 3.78 605 Toothpaste 8.00 1 8.00 704 Dish Soap 7.50 1 7.50 710 Detergent 24.12 1 24.12 802 Chewing gum 2.00 5 10.00 843 Dishes 49.99 1 49.99 Totals: 27 207.58 Notes: – This is an example of output for only one customer’s transactions. Some shopping lists consist of only 1 item, while others may be very lengthy. This is what would be returned to the customer, showing total number of items purchased (including all categories) and the total sale price to be paid. – Each Customer Receipt is identified by a number, starting from 1 for the first customer and ranging upwards, incrementing by 1 for each new customer. In this example, Customer Receipt # 98 is assumed. Assume there is no overflow problem with this number. Page 10 of 12 Use-Case 5: TYPICAL CATEGORY INVENTORY REPORT FORMAT Output sent to: stdout and to: Inventory500.dat The following line is not output, use as a guide for report spacing 123456789012345678901234567890123456789012345678901234567890 Category Name: Food Canned Category Code: 500 Code Item Name NumItems TotSale 501 Beans Green 73 202.94 509 Beans Brown 157 351.68 … … … … (more data) 585 Chicken Broth 83 156.87 Total Items Sold: 430 Total Sales: 1267.98 Notes: – This is an example of output for only one Category, namely Category Code 500 representing Food Canned. – Your program will generate a similarly formatted report for all of the categories for the stdout report. The format of each category report begins with the Category Name and ends with the Total Sales for that category. – For all the individual types of items for which output is sent to stdout, your program will produce also a direct access type, binary file (named Inventory500.dat in the example shown above) for storing the data for each Code record (highlighted in red). The filename Inventory500 is simply a concatenated string consisting of “Inventory” and “500” (or the Category Code, expressed as string of digits). A separate file, with appropriate code inserted in the filename, must be produced for each Category (e.g. Inventory100.dat, Inventory200.dat, and so on). – Stating the above point again – the red lines above are outputted to both stdout and to the binary output file for that particular category code. – Recall that direct access binary files must have all records of the same length, so define data structures appropriately. – The use of ellipses (…) above indicates that more data would exist, in general, than is shown. – Figure 2 may be useful in visualizing how to organize data structures. Page 11 of 12 Use-Case 6: DAILY SUMMARY REPORT FORMAT Output sent to: stdout The following lines are not input, rather guides for report spacing 1234567890123456789012345678901234567890123456789012345678901234567890 Daily Summary Report Code Category Name #Items Sold Tot Sales Amt 100 Food Vegetables 250 1300.45 200 Food Meats 130 5680.76 300 Food Breads Grains 110 456.43 400 Food Frozen 365 3485.96 500 Food Canned 430 1267.98 600 Toiletries 200 2130.00 700 Cleaning Supplies 100 980.13 800 Other 46 2767.11 Total Customers 114 Total Items Sold 1631 Total Sales 18068.82 Notes: – This is an example of output for a typical daily sales. – The total number of customers is being reported, along with total items sold and total sales achieved in all categories. Page 12 of 12 Figure 1, A typical grocery shopping experience at the checkout, and a possible data structure to hold data. F

Attachments:

Looking for a similar assignment? Get help from our qualified experts!

"Our Prices Start at $9.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!":

Order a Similar Paper Order a Different Paper