CS167/467 C Programming Fall 1999 The wood-screw inventory Goals To write a program that uses a single array of integers, and functions to contain subtasks. Problem description Write a C program that keeps an inventory of different sizes of wood-screw. The sizes are 4, 6, 8, 10, and 12. Assume all the screws are the same length, and made from the same material. The program should start from a zero inventory and be able to accept input in the form of a screw size and an amount by which to increase or decrease (if negative) the holding of that size of screw. The cost of each supply item is constant and is hard-coded in the program. At the end of the input, a list of screw sizes, their amounts and the total money worth of the inventory should be printed. Procedure Follow these steps to end up with a successful program: 1. Think of the program in terms of at least three separate subtasks, which you should write as separate functions: a. reading a 'transaction', i.e. a line of input that specifies the screw size and an increase or decrease amount b. updating the inventory, i.e. the number of each size of screw held c. printing the inventory d. you may want to treat initialization as a separate subtask 2. Write the main program to call these three functions appropriately. 3. The program should create an "empty" inventory that can handle the screw sizes mentioned above, here with their (fixed) unit cost: 4 $0.30 6 $0.35 8 $0.45 10 $0.50 12 $0.65 Deliverables: o your source code, suitably commented and with good layout o the output produced by the program with the following input sequence (note the use of a special value as a sentinel). The first number is the size of screw, and the second is the change in the inventory amount. 6 1000 8 1500 10 1200 4 500 12 100 8 -255 4 -62 10 -720 8 500 4 100 9999 0 o your source code e-mailed to the grader, login name byao. o a hard copy handed to me (RTH) Notes and hints o the program is an example of a "loop" program where the main task is a loop of some sort. Input is done within the loop. The output phase, is separate, however, and is done after all input and processing have been completed. o prompt the user for input, mentioning especially the sentinel value used for teminating the input. o display screen output with reasonable layout, taking note of the display of money values. Use %10.2f as a format specifier o use an array for the numbers of screws of each size. Index the array by applying a function to the screw size: e.g. screw size 4 goes in array element 0, size 6 goes in element 1 etc. This will be described in class. Due Date Submit your completed assignment before 5pm. on Wednesday Nov. 3rd.