Page 1 Computer Science 255 First Hour Exam Name ______________________ Thursday, Oct. 3 100 pts. 1. (10 pts.) List and briefly describe the three file organizations possible in COBOL. 2. (10 pts.) Consider the following record: STUDENT-RECORD where LAST is 20 characters alphanumeric FIRST is 20 characters alphanumeric MI is one character alphabetic GPA is three characters numeric with an understood decimal place between the first and second position CLASS is two characters alphabetic. Write a complete COBOL record description for the above, paying particular attention to the data type of a field. III. Move statements. Be sure to indicate any spaces with a check-mark. a. (10 pts.) Suppose that we have 02 A PIC X(5) VALUE "ABCDE" 02 B PIC X(3). 03 C PIC X(7) JUSTIFIED RIGHT. 03 D PIC XX/XXBX. what is the effect of the following MOVE statements? MOVE A TO B _______________ MOVE A TO C _______________ MOVE A TO D _______________ b. (15 pts.) Suppose we have 02 A PIC S99V99 VALUE -12.34. 02 B PIC 9(5)V99 VALUE 12345.67. 02 C PIC $$$,$$9.99CR. 02 D PIC ZZ,ZZ9.99. 02 E PIC ++,++9.99. 02 F PIC 99.99 what is the effect of the following MOVE statements? MOVE A TO C __________ MOVE B TO C __________ MOVE B TO D __________ MOVE A TO E __________ MOVE B TO F __________ IV. Implement the following Pascal statements in COBOL: a. (5 pts.) if (score < 60) then begin writeln('fail'); FailCntr := FailCntr + 1 end else if (score < 90) then begin writeln('pass'); PassCntr := PassCntr + 1 end else begin writeln('outstanding'); GreatCntr := GreatCntr + 1 end b. (5 pts) while (eno <> sentinel) do begin writeln(eno); readln(EmpFile,eno) end. c. (10 pts.) for i := 1 to 3 do for j := 4 downto 2 do writeln(i,j) What is the effect of this code? V. (35 pts.) The file INV.DAT contains records with a 10 digit item number, a 20 character item description, a 3 digit amount-on-hand field, and a 5 digit unit-cost field (999V99). On this and the following page, write a complete COBOL program which will read the file and print, for each record in the file, a line with the item number, item description, amt-on- hand, unit-cost, and amount (calculated as the product of the amt-on-hand and unit-cost fields). Use suitable edit fields, but do not print headers or footers. Assume that the file is terminated by a sentinel record with an item number of all 9's. additional workspace for problem V