Page 1 COMPUTER SCIENCE 255 FIRST HOUR EXAM NAME ________________________ Friday, Sept. 24 10:00 AM 100 pts. 1. Briefly describe the four divisions of a COBOL program (10 pts.) IDENTIFICATION DIVISION ENVIRONMENT DIVISION DATA DIVISION PROCEDURE DIVISION 2. What do the letters in COBOL stand for? (5 pts.) 3. Suppose that you have a program called INVENTORY.COB. What commands would you type on the VAX to compile, link, and run the program? (5 pts.) 4. Name the three basic control structures (5 pts.) 5. Translate the following COMPUTE statement into ADD, SUBTRACT, MULTIPLY, and DIVIDE statements (using only those necessary). Invent any new variable names you need, but make sure that the values of A, B, C, and D are unchanged. Don't worry about the PICTURE clauses for any of the variables (including the ones you invent) (5 pts.) COMPUTE X = (A + B) / (C - D) END-COMPUTE. 6. Suppose that we have the following: A PIC XXX VALUE "ABC". B PIC 999V999 VALUE 123.456 C PIC 99V99 VALUE 12.34 D PIC ZZ,ZZ9.999 E PIC 99.99 F PIC 99V99 G PIC XBX/X H. PIC XXX What would be the result of the following MOVE statements (i.e., what would the destination field look like if it were printed)? Be careful to indicate the location of any spaces. (10 pts.) MOVE A TO G MOVE A TO H MOVE B TO D MOVE C TO D MOVE B TO E MOVE C TO F 7. File description (15 pts.) Suppose that the file "PARTS.DAT" contain records as follows: PNO field consisting of AISLE two characters alphanumeric SHELF one character alphabetic BIN two characters numeric PNAME ten characters alphanumeric AMT three numeric digits UNIT-COST a dollar amount < $999.99. Use an understood decimal place. Write a record description for this file. 8. A complete COBOL program On this and the following pages, you will be asked to write a complete COBOL program to solve the following problem: The file "CLASS.DAT" contains records organized as follows: STUDENT-NAME ten characters alphanumeric EXAM-1 three digit numeric EXAM-2 three digit numeric EXAM-3 three digit numeric The file is terminated by a sentinel record with STUDENT-NAME all "Z"'s. You are to write a program which will read the records in this file and which will print a line for each student with the student's name, exam scores, and exam average. Output is to be directed to the file "OUTPUT.LIS". Do not worry about headers or footers for this program, and for this program no internal documentation (comments) are necessary). 1. (5 pts.) Give the IDENTIFICATION DIVISION for this program. 2. (5 pts.) Give the ENVIRONMENT DIVISION for this program. 3. (15 pts.) Give the DATA DIVISION for this program 4. (20 pts.) Give the PROCEDURE DIVISION for this program.