CSCI-20 Linked Lists Lab #2, due 2/22/16 Please work in groups of three on this project. Do not work alone. Design this first, and divide the work so each person does about 1/3 of the coding, as separate files. Then integrate (link) the parts into a working program. Put the individual author's name in the notes at the top of each file, and put all team member's names in the notes at the top of main()'s source file. Your job is to write a simulation of a series of cashier's shifts on a point-of-sale (POS) terminal (e.g., a cash register). You will model simplified shifts for a POS terminal running sale transactions for cash only in a tax-free environment. You will use 2 lists. The first list will be implemented in an array of structs, and will contain the store’s inventory file. Records in this array-based list will contain a single item’s item number, description and unit price. You will create this list once, at program startup, and it will remain unchanged for the duration of the program. The second list will be a singly-linked linked list of allocated list elements, each containing the quantity, item number, description, and unit price of one line item in a transaction. The linked list will contain all the line items in a single transaction, and will be cleared before each transaction. Input to your program will come from 2 files, and output will go to an audit text file. You may assume the input files are in the correct format. Your output is a complete audit (record) of the shift activity, e.g. enough information to completely reproduce the activity happening at the terminal. The inventory list will be in an ordinary text file called “items.txt” in the current working directory. The format will be as follows: The first line contains the store number (max 4 digits), the POS terminal number (max 3 digits), and the cashier’s starting bank balance (max 6 digits, format 4.2), all tab-separated and terminated by a newline. The rest of the lines in the file contain item number (max 4 digits), description (maximum of 40 characters, which may include spaces), and price (max 6 digits, format 4.2), tab-separated and terminated by a newline. The last item in the file will have the number 9999. There will be no more than 25 items in inventory. For example: 1234 321 100.00 1111 The item numbered 1111 2222 This is item number 2222 1234 And this item is 1234 2345 Here we have # 2345! 3333 Item 3333 here at last 4444 Another load of 4444! 9999 This is the last, 9999 12.98 14.50 100.00 4.49 12.98 29.95 9.99 The transaction file will be an ordinary text file called “transact.txt” in the current working directory. It will contain 4 types of records identifiable by their first character. Both ‘I’ and ‘V’ records will contain quantity (integer, max 3 digits) and item number (same as in inventory), as tab-separated fields. The ‘I’ records will be sale items in the customer’s “basket”. The ‘V’ records will be items in the basket that the customer decided not to buy, and therefore must be removed from the transaction list. The ‘T’ and ‘Z’ records will consist of the letters alone on the line. The ‘T’ record will end the transaction, and add the cash value of the transaction to the basket. The ‘Z’ record closes the shift and causes the end-of-shift processing to happen. There may be another shift in the input file after the ‘Z’ record. Stop processing when you reach the end of file. You may assume end-of-file will immediately follow a ‘Z’ record (perhaps after a blank line if you hit Enter there). For example: I I V T I I T Z I I V T Z 2 1 2 1234 1111 1234 1 2 9999 2345 2 1 1 1234 9999 2345 ‘I’ (item) records represent an item to be added to the list of items in the transaction. You may not assume an item will be in the inventory list. ‘V’ (void) records represent an item already in the transaction, which the customer changed his or her mind about, and which must be removed from the list. You must match on both quantity and item number to remove an item from the list. You may not assume a ‘V’ item corresponds to an actual item in the transaction. If there is no match, print an error message to the audit file. If a ‘V’ record matches more than one line in the transaction, remove the LAST match of the matching lines. For ‘I’ and ‘V’ records print a message to the audit file indicating the action taken, either added item to list, tried to sell a nonexistent item, removed an item from list, or tried to void a nonexistent item. Show the quantity and item number in these messages. ‘T’ (total) records represent the completion of the transaction. Each transaction will result in an increase in the amount of cash in the cashier’s drawer. Therefore, on seeing the ‘T’ record, you will need to calculate the transaction total and add it to the cash in drawer. You may not assume the ‘T’ record will occur when there are items in the list, i.e., the customer may have voided all the items, or there may be 2 ‘T’ records in a row. In these cases, the transaction total is 0. Each ‘T’ record advances the transaction number, so keep a variable for transaction number that starts at one and increment it after each transaction. For each transaction, print the items currently in the transaction (in the same sequence they were entered, without voided lines), one per line, the total (on its own line), and the store number, POS terminal number, cashier's name (use one of your first names), and transaction number on a line below the total. The ‘Z’ (zero-out, or close) record marks the end of the shift. You will print the current transaction number and the final drawer balance to the audit file. Then re-initialize your shift variables for the next shift. I put two input files on my Web site. You may use my inventory file for all your tests. You must create a second transaction file that will exercise all the statements in your program at least one time, and will sell at least one of each item in inventory. Test with both (or more) transaction files and turn in the data and resulting audit files. You must create a separate implementation file and header file for your linked list class. You may, if you wish, create a class for the array-based list. If you do, create implementation and header files for it also. If you do not use a class for the array-based list, it may be defined in the main source file. You must use good modular (top-down) design for this program, good functional decomposition, and good style for the code. Design this (completely) before you try to write any code (except perhaps stubs to test concepts). A (very) high level design might start out something like this: initialize read inventory file into array-based list. while( it isn’t end-of-file ) initialize shift totals read from the transaction file while( it isn’t the ‘Z’ record ) switch( first letter on line ) case ‘I’ : handle inventory line, break; case ‘V’ : handle void line, break; case ‘T’ : handle transaction total, break; default : handle error condition (or, do nothing?) end switch read a line from the transaction file end while handle zero-out record end while shut down Hints: You have to print the transaction lines in the same order as they were entered. To void lines, you will have to scan looking for the last match on quantity and item number (not the first) in sequence through the list. You may only keep ONE link in the list element, pointing to "next". This means you will have to plan your list operations carefully! For the transaction file, read each line, look at the first character on the line, and then parse the input line, after you know what type of data the line contains. The fields are tab-separated (‘\t’). You might consider using strtok(), or find() and substr(). Assume the input files are correctly formatted! Don’t spend a lot of effort on unneeded error checking. Save your effort for the two errors you will encounter, sold item not on file and void of not-sold item. You might want to write operator methods (==, !=) for your list items that compare on both the quantity and item number. How can you compare to both at once? For simplicity, you may put the 'next' pointers into the list elements themselves rather than using carriers to implement the linked list.