We have all gone shopping before, whether for groceries, computer gadgets or milk and eggs.

computer science


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. 

Related Questions in computer science category