Page 1 Computer Science 255 Final Exam Name ______________________ Wednesday, Dec. 15 4:00 PM 200 pts. Please Read All Questions Before Starting the Exam 1. (20 pts.) List and briefly describe the four DIVISIONS of a COBOL program. Give the name of each division, and explain the role of the division. 2. (20 pts.) List and briefly describe the three SECTIONS of the DATA DIVISION that we have discussed in class. Give the name of each section, and explain the role of each in the program. 3. (20 pts.) a. What do the letters in COBOL stand for? b. COBOL is (justifiably) known as a verbose language. What was the idea in doing this? In particular, why have ADD, SUBTRACT, MULTIPLY, and DIVIDE statements when a perfectly acceptable COMPUTE statement exists? c. Unless directed otherwise, COBOL generally stores numeric data as a string of characters. Why is this? Give an exception that we have discussed. d. Who was G. M. Hopper, and what does she have to do with CSci 255? 4. (20 pts.) List and briefly describe the three file organizations available in COBOL. As a part of your description (but certainly not all of it), give sample SELECT statements. 5. (10 pts.) The GENERATE statement for the COBOL report writer replaces a number of statements that the programmer would otherwise have to write to manage page headers and page footers. Assuming reasonable names for variables, write the statements which are made unnecessary by the GENERATE statement in the statement: GENERATE DETAIL-LINE. (do not worry about control breaks in giving your answer) 6. (15 pts.) Write a description for a report writer detail line with all three of the following fields: a) A last name, alphanumeric, 15 characters long, any characters possible, to be taken from the field EMP-NAME. b. A numeric field that has one decimal place and can store any number less than 10,000. Include leading zero suppression and replacement by blanks up to (but not including) the first digit to the left of the decimal point, and a possible comma in the appropriate position. The value for this field is taken from TOTAL-HOURS. c. A currency field with check protection asterisks, two decimal places, a currency symbol, and a CR to be printed if the number is negative. The value for this field is taken from CURRENT-BALANCE. 7. (20 pts.) a. Describe a table in COBOL to store exactly 100 entries described by the following. The PNO field is to be used as the key, and the table is in ascending order by PNO. Write the table so that a binary search verb could be used on the table. 01 PARTS-REC. 02 PNO PIC X(5). 02 PNAME PIC X(20). 02 INVENTORY PIC 9(5). b. Write the code necessary to load the table with exactly 100 data records from the file PARTS-FILE with record PARTS-REC. 8. (20 pts.) Consider the following Entity-Relationship diagram: SNO is the key for SALESPER, and CNO is the key for CUSTOMER. a. Decompose the above ER diagram into the description of two files. For each file, list (only) the name you want to give to the file, the names of the fields, and indicate keys and foreign keys. (continued on next page) b. Write a SELECT statement for the CUSTOMER file as an INDEXED file with indexes. Justify your choice of indexes, and give your justification for any fields you do not index (but say why you might consider indexing them). 9. (20 pts.) The file STUDENT with fields SNO, SNAME, and ADVISOR is described as an indexed file with primary key over SNO and non-unique secondary key over ADVISOR. ADVISOR is the faculty number of the student's advisor. Write the PROCEDURE DIVISION statements necessary to DISPLAY the names of the students advised by ADVISOR "F12345". 10. (35 pts.) The file PARTS-FILE contains records as follows: 01 PARTS-REC. 02 PNO PIC X(5). 02 PNAME PIC X(20). 02 INVENTORY PIC 9(5). The file MODIFY-FILE contains records as follows: 01 MODIFY -REC. 02 PNO-IN PIC X(5). 02 TRANSACTION PIC X. 88 INSERT-IN-INVENTORY VALUE "I". 88 DELETE-FROM-INVENTORY VALUE "D". 02 PNAME-IN PIC X(20) 02 INVENTORY-IN PIC 9(5) A code of "I" in the MODIFY-FILE indicates that the record is to be inserted into the output file. A code of "D" in the MODIFY-FILE indicates that the record is to be deleted. All files are SEQUENTIAL, in order by PNO and PNO-IN (although this does not need to be checked), and both files are terminated by a PNO value of "99999". On the following page, write the code necessary (procedure division only) to perform the indicated operations on the incoming master file, producing a new master file. Display an error message if a DELETE transaction is attempted on a nonexistent record, or if an attempt is made to insert an existing record. Working space for problem 10