Preparation of Mark List by reading data from a Student File (Line Sequential)


       IDENTIFICATION DIVISION.
       PROGRAM-ID. STUDENT-FILE-MARKLIST-PREPARATION.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER.
       OBJECT-COMPUTER.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT STU-FILE ASSIGN TO DISK
           ORGANIZATION IS LINE SEQUENTIAL.
       DATA DIVISION.
       FILE SECTION.
       FD  STU-FILE
           LABEL RECORDS ARE STANDARD
           VALUE OF FILE-ID IS "STU.DAT"
           DATA RECORD IS STU-REC.
       01  STU-REC.
           02 REGNO   PIC 999.
           02 NAME    PIC X(30).
           02 M1      PIC 999.
           02 M2      PIC 999.
           02 M3      PIC 999.
       WORKING-STORAGE SECTION.
       01  TM         PIC 999.
       01  EDT-REC.
           02 EREGNO  PIC ZZ9.
           02 ENAME   PIC X(30).
           02 EM1     PIC ZZ9.
           02 EM2     PIC ZZ9.
           02 EM3     PIC ZZ9.
           02 ETM     PIC ZZ9.
           02 RESULT  PIC X(20).
       01  SL         PIC X(40) VALUE ALL "-".
       01  DL         PIC X(40) VALUE ALL "=".
       01  PAUSE      PIC X.
       PROCEDURE DIVISION.
       MAIN-PARA.
           PERFORM OPEN-PARA.
       READ-PARA.
           READ STU-FILE RECORD AT END GO TO CLOSE-PARA.
           COMPUTE TM = M1 + M2 + M3.
           IF TM NOT < 240
              MOVE "Distinction" TO RESULT
           ELSE IF TM NOT < 180
                   MOVE "First Class" TO RESULT
                ELSE IF TM NOT < 150
                        MOVE "Second Class" TO RESULT
                     ELSE
                        MOVE "Failed" TO RESULT.
           MOVE REGNO TO EREGNO.
           MOVE NAME TO ENAME.
           MOVE M1 TO EM1.
           MOVE M2 TO EM2.
           MOVE M3 TO EM3.
           MOVE TM TO ETM.
           DISPLAY (01 01) SPACES.
           DISPLAY (02 01) SL.
           DISPLAY (03 12) "M A R K   L I S T".
           DISPLAY (04 01) DL.
           DISPLAY (05 01) "   Register No : " EREGNO.
           DISPLAY (06 01) "          Name : " ENAME.
           DISPLAY (07 01) "      Marks in  ".
           DISPLAY (08 01) "     Subject-1 : " EM1.
           DISPLAY (09 01) "     Subject-2 : " EM2.
           DISPLAY (10 01) "     Subject-3 : " EM3.
           DISPLAY (12 01) "   Total Marks : " ETM.
           DISPLAY (14 01) "        Result : " RESULT.
           DISPLAY (16 01) DL.
           ACCEPT PAUSE.
           GO TO READ-PARA.
       OPEN-PARA.
           OPEN INPUT STU-FILE.
       CLOSE-PARA.
           DISPLAY " ".
           CLOSE STU-FILE.
           STOP RUN.

No comments:

Post a Comment