ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT STUDENT-FILE
ASSIGN TO 'C:\PCOBWIN\ROGERS\SCORES.TXT'
ORGANIZATION IS LINE SEQUENTIAL.
SELECT REPORT-CARDS
ASSIGN TO 'C:\PCOBWIN\ROGERS\REPORT.TXT'
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD STUDENT-FILE
DATA RECORD IS STUDENT-RECORD.
01 STUDENT-RECORD.
02 STUDENT-ID PIC X(5).
02 STUDENT-NAME PIC X(25).
02 STUDENT-TEST-SCORE-1 PIC 9(3).
02 STUDENT-TEST-SCORE-2 PIC 9(3).
02 STUDENT-TEST-SCORE-3 PIC 9(3).
FD REPORT-CARDS
DATA RECORD IS REPORT-RECORD.
01 REPORT-RECORD PIC X(80).
WORKING-STORAGE SECTION.
01 REPORT-ITEM.
02 REPORT-ID PIC X(5).
02 PIC X(5) VALUE SPACES.
02 REPORT-NAME PIC X(25).
02 PIC X(5) VALUE SPACES.
02 REPORT-GRADE PIC X.
01 AVERAGE-SCORE PIC 9(3)V9(2).
01 EOF-FLAG PIC X(3) VALUE 'NO '.
PROCEDURE DIVISION.
MAIN-LINE.
PERFORM INITIALIZATION-ROUTINE.
PERFORM THE-LOOP
UNTIL EOF-FLAG = 'YES'.
PERFORM CLEANUP-ROUTINE.
STOP RUN.
INITIALIZATION-ROUTINE.
OPEN INPUT STUDENT-FILE.
OPEN OUTPUT REPORT-CARDS.
READ STUDENT-FILE
AT END MOVE 'YES' TO EOF-FLAG.
THE-LOOP.
MOVE STUDENT-ID TO REPORT-ID.
MOVE STUDENT-NAME TO REPORT-NAME.
COMPUTE AVERAGE-SCORE ROUNDED =
( STUDENT-TEST-SCORE-1 +
STUDENT-TEST-SCORE-2 +
STUDENT-TEST-SCORE-3 ) / 3.
IF AVERAGE-SCORE NOT LESS THAN 93
MOVE 'A' TO REPORT-GRADE
ELSE IF AVERAGE-SCORE NOT LESS THAN 85
MOVE 'B' TO REPORT-GRADE
ELSE IF AVERAGE-SCORE NOT LESS THAN 76
MOVE 'C' TO REPORT-GRADE
ELSE IF AVERAGE-SCORE NOT LESS THAN 70
MOVE 'D' TO REPORT-GRADE
ELSE
MOVE 'F' TO REPORT-GRADE
END-IF
END-IF
END-IF
END-IF.
MOVE REPORT-ITEM TO REPORT-RECORD.
WRITE REPORT-RECORD.
READ STUDENT-FILE
AT END MOVE 'YES' TO EOF-FLAG.
CLEANUP-ROUTINE.
CLOSE STUDENT-FILE.
CLOSE REPORT-CARDS.