Page 1 Computer Science 255 Second Hour Exam Name _____________________________ Friday, Oct. 20 100 pts. 1. (15 pts.) After each operation on a file, the operating system stores a result code in a status field which can be specified by the programmer in the SELECT statement for that file. The status field is a two-byte alphanumeric field, of which the following is an example: 05 EMP-FILE-STATUS PIC XX. Status codes have the following meanings: If the status code is a "00" the operation completed normally. If the status code is a "10" the operation resulted in an END- OF-FILE condition. If the first character is a "2" then an "invalid key" condition exists, and the meaning of the second character is as follows: 2 - duplicate key condition 3 - record not found 4 - boundary condition. Write condition names to describe these codes (revising the 05 entry above), and then re-write the statement: IF EMP-FILE-STATUS = "23" THEN DISPLAY "EMPLOYEE RECORD NOT FOUND - RE-ENTER EMPLOYEE NUMBER" 2. (15 pts.) Suppose that we have the following: 01 SOURCE-FIELDS. 02 SRC-C PIC S9(5)V99 VALUE 12345.67. 02 SRC-D PIC S9(5)V99 VALUE -12345.67. 02 SRC-E PIC S9(5)V99 VALUE 0.03. 01 TARGET-FIELDS. 02 DST-A PIC ++++,+++,+++.++. 02 DST-B PIC ****,***,***.**. 02 DST-C PIC $$$$,$$$,$$$.$$. 02 DST-D PIC $$$$,$$$,$$$.$$CR. * What will be the result of the following? Be sure to indicate spaces by heck marks. MOVE SRC-C TO DST-A DISPLAY DST-A. DST-A = __________________ MOVE SRC-C TO DST-D DISPLAY DST-D. DST-D = __________________ * MOVE SRC-D TO DST-C DISPLAY DST-C. DST-C = __________________ MOVE SRC-D TO DST-D DISPLAY DST-D. DST-D = __________________ * MOVE SRC-E TO DST-C DISPLAY DST-C. DST-C = __________________ * 3. (30 pts.) Suppose that the file TIMESHEETS.DAT contains records with the following organization: 01 WORK-STUDY-REC. 02 STUDENT-NO PIC X(5). 02 STUDENT-NAME PIC X(10). 02 HOURS PIC 99. 02 RATE PIC 99V99. The file is terminated by a sentinel record with a STUDENT-NO of "99999". The records are sorted by STUDENT-NO (which is the key for this record). A given student may have several records in the file. Write the procedure division entries necessary to read the records in the file and produce, for each student, a detail line with the student's name and total pay. No headers or footers are needed for this exercise, and you do not need to print a line for each record - only a summary record for each student. Assume reasonable names for data division entries (i.e., you do not need to write data division entries). Additional workspace for problem #3 4. (10 pts.) Referring to the preceding problem (problem 4), write the detail line entry that you might use for printing out the timesheet records of problem 3 if you were using the COBOL report writer. 5. (30 pts.) The file MAJOR-FILE contains 20 records organized as follows: 01 MAJOR-REC. 02 MAJOR PIC X(10). 02 DEPT PIC X(10). a. Write the DATA DIVISION entry necessary to create a table of 20 entries of this record type ordered in ascending order by MAJOR. Arrange things so that you can use a binary search on the table. b. Write the code necessary to load the table with records from the file c. Using the COBOL binary search verb, write the code necessary to search the table for the major "CSB" and display the name of the department if found. If not found, print an error message.