Page 1 Computer Science 255 Final Exam Name _______________________ Monday, Dec. 11 200 pts. I. Basic stuff a. (5 pts.) What do the letters in COBOL stand for? b. (5 pts. each) Give brief definitions: 1. File 2. Entity 3. CODASYL 4. Data Flow Diagram 5. Projection operation (as in the relational algebra) 6. Level break program c. (25 pts.) We have studied three file organizations this term (sequential, relative, and indexed files). Briefly describe each, giving a significant advantage of using each organization. d. (20 pts.) The argument has been made that business data processing is a software engineering discipline, and that the life cycle model for software development is particularly well suited for business data processing. List and briefly describe the five steps in the life cycle model for software development. e. (20 pts.) Given the following: 01 CLASS-TABLE. 02 STUDENT-REC OCCURS 30 TIMES. 03 STUDENT-NAME PIC X(20). 03 EXAM OCCURS 3 TIMES PIC 999. 03 EXAM-AVERAGE PIC 999V99. Write the COBOL code necessary to calculate for each of the 30 students the average of each student's three exam scores and place the result in the EXAM-AVERAGE field for the student. That is, suppose that the STUDENT-NAME and EXAM entries in the array have been filled - write the code to fill the EXAM- AVERAGE entry for each student. II. Sequential files. (30 pts.) On the following page, do one (but only one) of the following two problems (a or b): a. The sequential file CUSTOMER-CHARGES contains records as follows: 01 CUSTOMER-REC. 02 CNO PIC 9(5). 02 CHARGE PIC 999V99. The file is sorted by CNO, and has a sentinel record with CNO = 99999. Write the code necessary to print, for each customer, the customer's name and total charges (not each charge - only the total). Check that the records are indeed in sequence, and DISPLAY an error message and take appropriate action if an out-of-sequence condition is discovered. b. The sequential file CUSTOMER-FILE contains records as follows: 01 CUSTOMER-REC. 02 CNO PIC 9(5). 02 CNAME PIC X(20). 02 CURRENT-CHARGES PIC 999V99. The sequential file CUSTOMER-CHARGES is as in part (a). Both files are sorted by CNO, and both have sentinel records with CNO=99999. Write the code necessary to read both files and produce an updated file reflecting the charges made by a customer. Reject (and DISPLAY an error message) charge records for which there does not exist a corresponding customer. Sequence checking is not necessary with this problem. Workspace for problem II. III Indexed files. a. Consider the entity-relationship diagram given below for tapes rented to customers by a video store. TNO is the key for the TAPE file, and CNO is the key for the CUSTOMER file.: The following files were recommended to implement this diagram: TAPE(TNO, TNAME) CUSTOMER(CNO, CNAME) RENT(CNO, TNO, DAYS) a. (15 pts.) Identify, by file i. Primary keys TAPE CUSTOMER RENT ii. Foreign keys (list file and fields) b. (10 pts.) Write a FD statement and a SELECT statement for the RENT file. Use reasonable data types and lengths. c. (10 pts.) Assuming reasonable FD and SELECT statements for the CUSTOMER file, write the COBOL statements necessary to read the unique record for customer "C12345" and DISPLAY that customer's name. d. (15 pts.) Using your answer to part (b) and assuming reasonable FD and SELECT statements for the other two files, write the COBOL statements to list the tapes rented by the customer with CNO = "C12345". IV. Relative files (20 pts.) The file EMP-FILE is a relative file (RELATIVE KEY EMP-FILE- KEY) with records organized as follows: 01 EMP-REC. 02 ENO PIC X(5). 02 ENAME PIC X(10). 02 NEXT-EMP PIC 999. NEXT-EMP is the record number of the next record in the file. Record number 1 is a list header record with ENO = "99999" and NEXT-EMP containing the record number of the first "real" record in the file (as with the order invoice exercise). The final record in the list has a NEXT-EMP value of 1 (pointing back to the sentinel record). Assuming that the file is open, write the COBOL code necessary to read the file in the order given by the NEXT-EMP links and DISPLAY each ENAME in turn.