Pages

COBOL Program for Printing Mark List using a table

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 MARK LIST for each student 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 NAME   PIC X(30).
              03 M1     PIC 999.
              03 M2     PIC 999.
              03 M3     PIC 999.
              03 TM     PIC 999.
              03 RESULT PIC X(20).
       01  E-STU-REC.
           02 E-REGNO   PIC ZZ9.
           02 E-M1      PIC ZZ9.
           02 E-M2      PIC ZZ9.
           02 E-M3      PIC ZZ9.
           02 E-TM      PIC ZZ9.
       01  NOS   PIC 999.
       01  I     PIC 999.
       01  PAUSE PIC X.
       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.
           PERFORM DISP-PARA VARYING I FROM 1 BY 1 UNTIL I > NOS.
           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.
           MOVE REGNO(I) TO E-REGNO.
           MOVE M1(I) TO E-M1.
           MOVE M2(I) TO E-M2.
           MOVE M3(I) TO E-M3.
           MOVE TM(I) TO E-TM.
           DISPLAY(01 01) ERASE.
           DISPLAY(01 02) "-----------------------------------".
           DISPLAY(02 05) "         MARK LIST".
           DISPLAY(03 02) "-----------------------------------".
           DISPLAY(05 05) "Register No. : " E-REGNO.
           DISPLAY(06 05) "        Name : " NAME(I).
           DISPLAY(07 05) " Marks for".
           DISPLAY(08 05) "       Sub-1 : " E-M1.
           DISPLAY(09 05) "       Sub-2 : " E-M2.
           DISPLAY(10 05) "       Sub-3 : " E-M3.
           DISPLAY(11 02) "-----------------------------------".
           DISPLAY(12 05) " Total Marks : " E-TM.
           DISPLAY(13 05) "      Result : " RESULT(I).
           DISPLAY(14 02) "===================================".
           ACCEPT PAUSE.


No comments:

Post a Comment