IDENTIFICATION DIVISION.
PROGRAM-ID. CALCULATE-AVERAGE-GPA.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
    SELECT STUDENT-FILE ASSIGN TO "STUDENT.DAT".

DATA DIVISION.
FILE SECTION.
FD STUDENT-FILE.
01 STUDENT-RECORD.
   05 STUDENT-ID PIC X(8).
   05 GPA PIC 9V99.

WORKING-STORAGE SECTION.
01 TOTAL-GPA PIC 9V99 VALUE 0.
01 NUM-STUDENTS PIC 9(4) VALUE 0.
01 AVERAGE-GPA PIC 9V99.

PROCEDURE DIVISION.
MAIN-LOGIC.
    OPEN INPUT STUDENT-FILE.
    READ STUDENT-FILE INTO STUDENT-RECORD.
    PERFORM UNTIL (STUDENT-RECORD IS NULL)
        ADD GPA TO TOTAL-GPA
        ADD 1 TO NUM-STUDENTS
        READ STUDENT-FILE INTO STUDENT-RECORD
    END-PERFORM.
    CLOSE STUDENT-FILE.
    COMPUTE AVERAGE-GPA = TOTAL-GPA / NUM-STUDENTS.
    DISPLAY "Average GPA: ", AVERAGE-GPA.
    STOP RUN.
