The wood-screw inventory
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:
- Write a one sentence problem statement.
- Write the problem description, as given above.
- Do a TDSR analysis for tasks and subtasks. Draw the TDSR diagram that you get from this analysis.
- Write a C program code from your analysis in 3.
- Create a source file using the editor.
- Compile the source code using gcc.
- The program should create an "empty" inventory that can handle the screw sizes mentioned above, here with their unit cost:
4 $0.30
6 $0.35
8 $0.45
10 $0.50
12 $0.65
- Deliverables:
- your design document with its three sections: problem statement, problem description, TDSR diagram.
- your source code, suitably commented and with good layout
- the output produced by the program with the following input sequence (note the use of a special value as a sentinel -- see page 69). The first number is the size of screw, and the second is the inventory change.6 1000
8 1500
10 1200
4 500
12 100
8 -255
4 -62
10 -720
8 500
4 100
9999 0
- your source code e-mailed to the grader, login name salahmed.
Notes and hints
- the design needs to show that all the input is not done before processing starts. This is an example of a "loop" design where the top-level task is a loop of some sort. The output phase, is separate, however, and is done after all input and processing have been completed.
- prompt the user for input, mentioning especially the sentinel value.
- display screen output with reasonable layout, taking note of the display of money values. Use %10.2f as a format specifier
- 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.
- when you are ready to produce the final output of the program, redirect the standard output produced by
cout
into a file by typing:
a.out > outputfile
which you can then print on the lineprinter.
- mail your source code with:
mail salahmed < filename.c
Due Date
Submit your completed assignment before 5pm. on Friday March 21st.