Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

Program to print mark sheet of a student with grades

Posted By: Idelia Miller     Category: Cobol     Views: 14975

Program to print marksheet of a student with grades.

Code for Program to print mark sheet of a student with grades in Cobol

       IDENTIFICATION DIVISION.
        PROGRAM-ID. MARKSHEET.

       ENVIRONMENT DIVISION.
        INPUT-OUTPUT SECTION.
         FILE-CONTROL.

           SELECT FILE-READ ASSIGN TO DISK
            ORGANIZATION IS LINE SEQUENTIAL.

           SELECT FILE-WRITE ASSIGN TO DISK
            ORGANIZATION IS LINE SEQUENTIAL.

       DATA DIVISION.
        FILE SECTION.

         FD FILE-READ
            VALUE OF FILE-ID IS "RESULT.DAT".
         01 F-REC-IN.
            02 ROLL-IN  PIC 9(2).
            02 NAME-IN  PIC X(28).
            02 MARKS-IN PIC 9(2) OCCURS 5 TIMES.

         FD FILE-WRITE
            VALUE OF FILE-ID IS "MARKSHET.RPT".
         01 F-WRITE-OUT PIC X(83).   

        WORKING-STORAGE SECTION.
         77 COUNT-DIST  PIC 99 VALUE ZEROS.
         77 COUNT-FIRST PIC 99 VALUE ZEROS.
         77 COUNT-SEC   PIC 99 VALUE ZEROS.
         77 COUNT-PASS  PIC 99 VALUE ZEROS.
         77 COUNT-FAIL  PIC 99 VALUE ZEROS.

         77 EOF PIC X VALUE 'Y'.
         77 IND PIC 9 VALUE 1.

         77 TOTAL-TEMP PIC 9999 VALUE ZEROS.
         77 PER-TEMP PIC 99V99.
            88 DIST   VALUE 70 THRU 100.
            88 FIRST1 VALUE 60 THRU 69.
            88 SECOND VALUE 50 THRU 59.
            88 PASS   VALUE 40 THRU 49.

         77 HEAD-LINE1 PIC X(83)
            VALUE "<---------------------------------MARKSHEET----------
      -           "----------------------->".
         77 HEAD-LINE2 PIC X(83)
            VALUE "ROLL             NAME               <---MARKS----> TO
      -           "TAL  AVG      CLASS".
         77 HEAD-LINE3 PIC X(83)
            VALUE " NO                                 S1 S2 S3 S4 S5".

         77 DASH-LINE PIC X(77) VALUE ALL "-".

         77 FOOTER1 PIC X(20) VALUE "      DISTINCTION  :".
         77 FOOTER2 PIC X(20) VALUE "      FIRST  CLASS :".
         77 FOOTER3 PIC X(20) VALUE "      SECOND CLASS :".
         77 FOOTER4 PIC X(20) VALUE "      PASS   CLASS :".
         77 FOOTER5 PIC X(20) VALUE "      FAIL         :".

      *   1         2         3         4         5         7         8
      *1234567890123456789012345678901234567890123456789012345678901234567890123456789
      *<-----------------------------MARKSHEET------------------------------>

      *ROLL             NAME             <---MARKS----> TOTAL  PER      CLASS
      * NO                               S1 S2 S3 S4 S5  999  99.99
      *      DISTINCTION  :
      *      FIRST  CLASS :
      *      SECOND CLASS :
      *      PASS   CLASS :
      *      FAIL         :
         01 REC-OUT.
            02 ROLL-OUT PIC ZZZ9.
            02          PIC XX.
            02 NAME-OUT PIC X(27).
            02          PIC XX.
            02 MARKS-OUT PIC ZZ9 OCCURS 5 TIMES.
            02 TOTAL-OUT PIC ZZZZ9.
            02 PER-OUT PIC ZZ99.99.
            02           PIC XX.
            02 CLASS-OUT PIC X(12).

       PROCEDURE DIVISION.
         BEGIN.
           OPEN INPUT FILE-READ.
           OPEN OUTPUT FILE-WRITE.

           PERFORM HEADING-PARA.

           PERFORM UNTIL EOF = 'N'
            READ FILE-READ
             AT END MOVE 'N' TO EOF
             NOT AT END PERFORM PROCESS-PARA
           END-PERFORM.

           PERFORM SUMMERY-PARA.

           CLOSE FILE-READ.
           CLOSE FILE-WRITE.
           STOP RUN.

         HEADING-PARA.
            WRITE F-WRITE-OUT FROM HEAD-LINE1
            WRITE F-WRITE-OUT FROM HEAD-LINE2 AFTER ADVANCING 1 LINES.
            WRITE F-WRITE-OUT FROM HEAD-LINE3 AFTER ADVANCING 1 LINES.
            WRITE F-WRITE-OUT FROM DASH-LINE  AFTER ADVANCING 1 LINES.

         PROCESS-PARA.
            MOVE ROLL-IN TO ROLL-OUT
            MOVE NAME-IN TO NAME-OUT
            MOVE ZEROS TO TOTAL-TEMP 
            PERFORM 5 TIMES
                COMPUTE TOTAL-TEMP = TOTAL-TEMP + MARKS-IN (IND)
                MOVE MARKS-IN (IND) TO MARKS-OUT (IND)
                ADD 1 TO IND
            END-PERFORM

            MOVE 1 TO IND
            MOVE TOTAL-TEMP TO TOTAL-OUT

            DIVIDE 5 INTO TOTAL-TEMP GIVING PER-OUT PER-TEMP

            EVALUATE TRUE
             WHEN DIST
                MOVE "DISTINCTION" TO CLASS-OUT
                ADD 1 TO COUNT-DIST
             WHEN FIRST1
                MOVE "FIRST CLASS" TO CLASS-OUT
                ADD 1 TO COUNT-FIRST
             WHEN SECOND
                MOVE "SECOND CLASS" TO CLASS-OUT
                ADD 1 TO COUNT-SEC
             WHEN PASS
                MOVE "PASS CLASS" TO CLASS-OUT
                ADD 1 TO COUNT-PASS
             WHEN OTHER
                MOVE "FAIL" TO CLASS-OUT
                ADD 1 TO COUNT-FAIL
            END-EVALUATE

            WRITE F-WRITE-OUT FROM REC-OUT AFTER ADVANCING 1 LINES.

         SUMMERY-PARA.
            WRITE F-WRITE-OUT FROM DASH-LINE AFTER ADVANCING 1 LINES
            WRITE F-WRITE-OUT FROM FOOTER1 AFTER ADVANCING 1 LINES
            WRITE F-WRITE-OUT FROM COUNT-DIST
            WRITE F-WRITE-OUT FROM FOOTER2 AFTER ADVANCING 1 LINES 
            WRITE F-WRITE-OUT FROM COUNT-FIRST 
            WRITE F-WRITE-OUT FROM FOOTER3 AFTER ADVANCING 1 LINES
            WRITE F-WRITE-OUT FROM COUNT-SEC
            WRITE F-WRITE-OUT FROM FOOTER4 AFTER ADVANCING 1 LINES
            WRITE F-WRITE-OUT FROM COUNT-PASS
            WRITE F-WRITE-OUT FROM FOOTER5 AFTER ADVANCING 1 LINES
            WRITE F-WRITE-OUT FROM COUNT-FAIL.
  
Share: 


Didn't find what you were looking for? Find more on Program to print mark sheet of a student with grades Or get search suggestion and latest updates.

Idelia Miller
Idelia Miller author of Program to print mark sheet of a student with grades is from Frankfurt, Germany.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!