COBOL Program for preparing Result of Students using tables


A student record contains register no, name, marks of three subjects, total marks and result(use appropriate picture clause). Write a program in COBOL to accept required information of n number of students and process and print the results in a neat format.

    
    
       IDENTIFICATION DIVISION.
       PROGRAM-ID. STUDENT-TABLE-MARKLIST.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER.
       OBJECT-COMPUTER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  STUDENT.
           02 STU-REC OCCURS 100 TIMES.
              03 REGNO  PIC 999.
              03 FILLER PIC X.
              03 NAME   PIC X(30).
              03 M1     PIC 999.
              03 FILLER PIC X(3).
              03 M2     PIC 999.
              03 FILLER PIC X(3).
              03 M3     PIC 999.
              03 FILLER PIC X(3).
              03 TM     PIC 999.
              03 FILLER PIC X(3).
              03 RESULT PIC X(20).
       01  SL   PIC X(78) VALUE ALL "-".
       01  DL   PIC X(78) VALUE ALL "=".
       01  NOS  PIC 999.
       01  I    PIC 999.
       PROCEDURE DIVISION.
       MAIN-PARA.
           DISPLAY "Enter the Number of Students : ".
           ACCEPT NOS.
           PERFORM READ-PARA VARYING I FROM 1 BY 1 UNTIL I > NOS.
           PERFORM PROCESS-PARA VARYING I FROM 1 BY 1 UNTIL I > NOS.
           DISPLAY SL.
           DISPLAY "                              RESULT".
           DISPLAY SL.
           DISPLAY "RGN NAME                           M1    M2    M3
      -    " TM   RESULT".
           DISPLAY DL.
           PERFORM DISP-PARA VARYING I FROM 1 BY 1 UNTIL I > NOS.
           DISPLAY DL.
           DISPLAY " ".
           STOP RUN.
       READ-PARA.
           DISPLAY "Enter the Register Number : ".
           ACCEPT REGNO(I).
           DISPLAY "Enter the Name : ".
           ACCEPT NAME(I).
           DISPLAY "Enter three Marks : ".
           ACCEPT M1(I).
           ACCEPT M2(I).
           ACCEPT M3(I).
       PROCESS-PARA.
           COMPUTE TM(I) = M1(I) + M2(I) + M3(I).
           IF TM(I) NOT < 240
              MOVE "Distinction" TO RESULT(I)
           ELSE IF TM(I) NOT < 180
              MOVE "First Class" TO RESULT(I)
           ELSE IF TM(I) NOT < 150
              MOVE "Passed" TO RESULT(I)
           ELSE
              MOVE "Failed" TO RESULT(I).
       DISP-PARA.
           DISPLAY STU-REC(I).

No comments:

Post a comment