This is an open notes, open book, take-home exam - if you
have any problems see me - YOU MAY NOT DISCUSS THE EXAM QUESTIONS WITH
ANYONE BUT ME! Note this exam was posted on April 7th! It is due April 14th!
I take off 5 points per class day for late exams!
(For the flowcharting segments you may draw the portion by hand or if you are
in the Web class and sending it by e-mail, you can use the drawing in Word or
another package - it can be pretty rough - or send a scanned image - otherwise
you can send it by mail - postmark must be on or before November 13th)
Note: I am not trying to trick you - typos are probably just that, typos!
Please ask questions and correct any you find.
If you got programs to me by this weekend, you can excuse yourself from the
midsemester - you had to complete the set that were programming assignment #1
and you had to have made a good start (about 50%) on programming assignment #2.
(Note, I sent notes to those who are excused - if you have a question, email
me). If you excuse yourself, then the 10% of your grade that was for the
midsemester becomes part of the general grade for homework and programs. If you
were excused, you can opt to take the exam or you can opt to take the exam for
extra credit!
8.
9. 05 NUM1-WS PIC 9999 VALUE 45.12.
10. 05 NUM2-WS PIC XXX VALUE 43.2.
11. 05 NUM3-WS PIC 999V99 VALUE .52458.
12. 05 NUM4-WS PIC 999V999 VALUE 112834.
13. 05 NUM5-WS PIC 99V9 VALUE 123.45
14. 05 NUM6-WS PIC 99999 VALUE 427.12.
15.
16.
18.
19. 54321BLOUSE 296061200780001120004452
The Data Division and the Procedure Division are shown below:
DATA DIVISION.
FILE SECTION.
FD INPUT-FILE DATA RECORD IS INPUT-REC.01 INPUT-REC.05 ITEM-NO PIC X(5).
05 ITEM-NAME PIC X(10).
05 AMT1 PIC 9(3).
05 AMT2 PIC 99V99.
05 AMT3 PIC 99V999.
05 AMT4 PIC 999V99.
05 AMT5 PIC 9(5)V99.
FD PRINT-FILE DATA RECORD IS PRINTZ.01 PRINTZ. 05 FILLER PIC X.05 ITEM-NO-PR PIC X(5).
05 FILLER PIC XX.
05 ITEM-NAME-PR PIC X(10).
05 FILLER PIC XX.
05 AMT1-PR PIC ZZ9. 05 FILLER PIC XX. 05 AMT2-PR PIC Z9.99. 05 FILLER PIC XX. 05 AMT3-PR PIC Z9.99. 05 FILLER PIC XX. 05 AMT4-PR PIC $***.99. 05 FILLER PIC XX. 05 AMT5-PR PIC $$$,$$$.99. 05 FILLER PIC XX. 05 ANS1-PR PIC ZZ9.99. 05 FILLER PIC XX. 05 ANS2-PR PIC $***,***.99.05 FILLER PIC X.
WORKING-STORAGE SECTION.
01 INDICATORZ.05 EOF-IND PIC XXX VALUE "NO ".
01 WORK-AREAS.05 ANS1-WS PIC 999V99 VALUE 0.
05 ANS2-WS PIC 9(5)V99 VALUE 0.
PROCEDURE DIVISION.
MAINLINE.
PERFORM A-100-STARTUP. PERFORM B-100-PROCESS. PERFORM C-100-WRAPUP. STOP RUN.A-100-STARTUP.
OPEN INPUT INPUT-FILE OUTPUT PRINT-FILE.B-100-PROCESS.
READ INPUT-FILE AT END MOVE "YES" TO EOF-IND. PERFORM B-200-LOOP UNTIL EOF-IND = "YES".B-200-LOOP.
MOVE SPACES TO PRINTZ. MOVE ITEM-NO TO ITEM-NO-PR. MOVE ITEM-NAME TO ITEM-NAME-PR. MOVE AMT1 TO AMT1-PR. MOVE AMT2 TO AMT2-PR. MOVE AMT3 TO AMT3-PR. MOVE AMT4 TO AMT4-PR. MOVE AMT5 TO AMT5-PR. SUBTRACT AMT3 FROM AMT4 GIVING ANS1-WS. ADD AMT2 TO ANS1-WS. MOVE ANS1-WS TO ANS1-PR. ADD AMT5 TO ANS1-WS GIVING ANS2-WS. MOVE ANS2-WS TO ANS2-PR. WRITE PRINTZ AFTER ADVANCING 1 LINES.
READ INPUT-FILE AT END MOVE "YES" TO EOF-IND.C-100-WRAPUP.
CLOSE INPUT-FILE
PRINT-FILE.
Show the output line that would result from processing the record shown at the beginning of the problem. Be very precise in showing each character on the print line (this includes accounting for spaces etc.)
22.
23. IDENTIFICATION DIVISION.24. PROGRAM-ID. NEEDTOT.25. AUTHOR. GROCER.26. ENVIRONMENT DIVISION.27. INPUT-OUTPUT SECTION.28. FILE-CONTROL.29. SELECT INVEN-FILE30. ASSIGN TO "A:\INVEN.DAT".31. SELECT PRINT-FILE32. ASSIGN TO PRINTER.33. DATA DIVISION.34. FILE SECTION.35. FD INVEN-FILE
36. DATA RECORD IS INVEN-REC.37. 01 INVEN-REC.
38. 05 ITEM-NO PIC XXX.
39. 05 ITEM-NAME PIC X(20).
40. 05 ON-HAND PIC 9(5).
41. 05 COST PIC 999V99.
42. FD PRINT-FILE
43. DATA RECORD IS PRINTZ.44. 01 PRINTZ.
45. 05 FILLER PIC X.
46. 05 ITEM-NO-PR PIC XXX.
47. 05 FILLER PIC X(10).
48. 05 ITEM-NAME-PR PIC X(20).
49. 05 FILLER PIC X(10).
50. 05 ON-HAND-PR PIC ZZ,ZZ9.
51. 05 FILLER PIC X(10).
52. 05 COST-PR PIC $ZZ9.99.
53. 05 FILLER PIC X(13).
54. WORKING-STORAGE SECTION.55. 01 INDZ.
56. 05 MORE-RECS PIC XXX VALUE "YES".
57. 01 PAGE-CONTROL.
58. 05 LINE-CT PIC 99 VALUE 0.
59. 01 PAGE-HDR.
60. 05 FILLER PIC X(32) VALUE SPACES.
61. 05 FILLER PIC X(16)
62. VALUE "INVENTORY REPORT".63. 05 FILLER PIC X(32) VALUE SPACES.
64. 01 COL-HDR.
65. 05 FILLER PIC X(14) VALUE " ITEM # ".
66. 05 FILLER PIC XXXX VALUE "NAME".
67. 05 FILLER PIC X(25) VALUE SPACES.
68. 05 FILLER PIC X(7) VALUE "ON HAND".
69. 05 FILLER PIC X(10) VALUE SPACES.
70. 05 FILLER PIC X(7) VALUE " COST ".
71. 05 FILLER PIC X(13) VALUE SPACES.
72. PROCEDURE DIVISION.73. MAINLINE.74. PERFORM A-100-STARTUP.75. PERFORM B-100-PROCESS.76. PERFORM C-100-WRAPUP.77. STOP RUN.78. A-100-STARTUP.79. OPEN INPUT INVEN-FILE80. OUTPUT PRINT-FILE.81. B-100-PROCESS.82. READ INVEN-FILE83. AT END84. MOVE "NO " TO MORE-RECS.85. PERFORM B-200-LOOP86. UNTIL MORE-RECS = "NO ".87. B-200-LOOP.88. IF LINE-CT = 0 OR LINE-CT > 5589. PERFORM B-300-HDR-ROUT.90. MOVE SPACES TO PRINTZ.91. MOVE ITEM-NO TO ITEM-NO-PR.92. MOVE ITEM-NAME TO ITEM-NAME-PR.93. MOVE ON-HAND TO ON-HAND-PR.94. MOVE COST TO COST-PR.95. WRITE PRINTZ96. AFTER ADVANCING 1 LINES.97. READ INVEN-FILE98. AT END99. MOVE "NO " TO MORE-RECS.100. B-300-HDR-ROUT.101. WRITE PRINTZ FROM PAGE-HDR102. AFTER ADVANCING PAGE.103. WRITE PRINTZ FROM COL-HDR 104. AFTER ADVANCING 2 LINES.105. MOVE SPACES TO PRINTZ.106. WRITE PRINTZ 107. AFTER ADVANCING 1 LINES.108. MOVE 4 TO LINE-CT.109. C-100-WRAPUP.110. CLOSE INVEN-FILE111. PRINT-FILE.
For extra credit, include the code to figure out the average
cost of your merchandise and print that average cost on a second total line.
For extra credit explain the code that will cause the header routine to be
performed.