Home   Easy-Code    Forum  Updater 
Twitter Facebook



Program to read student file and find average marks for each student using cobol

Critics Rating:

Users Rating:

* PROGRAM TO READ STUDENT FILE AND FIND AVERAGE MARKS FOR EACH STUDENT.

***********************************************************************

   IDENTIFICATION DIVISION.

   PROGRAM-ID.

   ENVIRONMENT DIVISION.

   INPUT-OUTPUT SECTION.

   FILE-CONTROL.

      SELECT DATAFILE ASSIGN TO DISK

      ORGANIZATION IS LINE SEQUENTIAL.

   DATA DIVISION.

   FILE SECTION.

   FD DATAFILE

      LABEL RECORDS ARE STANDARD

      VALUE OF FILE-ID IS "MARKS.DAT".

   01 MARKS.

    02 SNO PIC 9(3).

    02 F PIC X(5).

    02 NAM PIC X(10).

    02 F PIC X(5).

    02 M1 PIC 9(3).

    02 F PIC X(5).      

    02 M2 PIC 9(3).

    02 F PIC X(5).

    02 M3 PIC 9(3).

   WORKING-STORAGE SECTION.

   01 UNDER.

    02 F PIC X(79) VALUE ALL "-".

   01 HEAD.

    02 F PIC X(4) VALUE SPACES.

    02 F PIC X(10) VALUE "ROLLNO".

    02 F PIC X(15) VALUE "NAME".

    02 F PIC X(10) VALUE "MATHS".

    02 F PIC X(10) VALUE "PHYSICS".

    02 F PIC X(12) VALUE "COMPUTERS".

    02 F PIC X(8) VALUE "TOTAL".

    02 F PIC X(10) VALUE "AVERAGE".

   77 EOF PIC A.

   77 TOT PIC 9(3).

   77 AVG PIC 9(3)V99.

   77 P PIC Z99.99.

   PROCEDURE DIVISION.

   MAIN-PARA.

      OPEN EXTEND DATAFILE.

      DISPLAY "DO YOU WANT TO INSERT THE RECORD(Y/N)".

      ACCEPT EOF.

   PERFORM X-PARA UNTIL EOF = "N" OR EOF = "n".

      CLOSE DATAFILE.

      MOVE "Y" TO EOF.

      DISPLAY (1 , 1) ERASE.

      DISPLAY (1 , 1) UNDER.

      DISPLAY (2 , 31) "STUDENTS MARKS LIST".

      DISPLAY (3 , 1) UNDER.

      DISPLAY (4 , 1) HEAD.

      DISPLAY (5 , 1) UNDER.

      OPEN INPUT DATAFILE.

      MOVE 6 TO LIN.

      PERFORM Y-PARA UNTIL EOF = "N".

      CLOSE DATAFILE.

      STOP RUN.

   X-PARA.

      DISPLAY (1 , 1) ERASE.

      DISPLAY "ENTER THE ROLLNO".

      ACCEPT SNO.

      DISPLAY "ENTER THE STUDENT NAME".

      ACCEPT NAM.

      DISPLAY "ENTER MARTHS MARKS".

      ACCEPT M1.

      DISPLAY "ENTER PHYSICS MARKS".

      ACCEPT M2.

      DISPLAY "ENTER COMPUTER MARKS".

      ACCEPT M3.

      WRITE MARKS.

      DISPLAY "DO YOU WANT TO CONTINUE(Y/N)?".

      ACCEPT EOF.

   Y-PARA.

      READ DATAFILE RECORD AT END MOVE "N" TO EOF.

      IF (EOF NOT = "N")

       DISPLAY (LIN , 7) SNO

       DISPLAY (LIN , 15) NAM

       DISPLAY (LIN , 31) M1

       DISPLAY (LIN , 42) M2

       DISPLAY (LIN , 53) M3

       COMPUTE TOT = M1 + M2 + M3

       DISPLAY (LIN , 63) TOT

       COMPUTE AVG = TOT /3

       MOVE AVG TO P

       DISPLAY (LIN , 70) P

       IF (LIN = 22)

       DISPLAY (24 , 50) "PRESS ANY KEY TO CONTINUE...."   

       ACCEPT LIN

       DISPLAY (6 , 1) ERASE

       MOVE 6 TO LIN

       ELSE

       ADD 1 TO LIN.

Courtesy, Source, References & Regards: Kishore AVGK

While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright@2009-2011 by KuGuNi.com. All Rights Reserved.