Home   Easy-Code    Forum  Updater 
Twitter Facebook



Program to create a data base file for blood donars for a hospital using cobol

Critics Rating:

Users Rating:

* PROGRAM TO CREATE A DATA BASE FILE FOR BLOOD DONARS FOR A HOSPITAL.

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

   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 "DONARS.DAT".

   01 DONAR.

    02 NAM PIC X(15).

    02 F PIC X(5).      

    02 ADS PIC X(30).

    02 F PIC X(5).

    02 AGE PIC 9(2).

    02 F PIC X(5).

    02 BGP PIC A.

   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(15) VALUE "DONAR NAME".

    02 F PIC X(5) VALUE SPACES.

    02 F PIC X(25) VALUE "ADDRESS".

    02 F PIC X(5) VALUE SPACES.

    02 F PIC X(5) VALUE "AGE".

    02 F PIC X(5) VALUE SPACES.

    02 F PIC X(15) VALUE "BLOOD GROUP".

   77 EOF PIC A.

   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) "BLOOD DONARS 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.

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

      ACCEPT EOF.

      MOVE "Y" TO EOF.

      DISPLAY (1 , 1) ERASE.

      DISPLAY (1 , 1) UNDER.

      DISPLAY (2 , 7) "BLOOD DONARS LIST WHOSE AGE BELOW 30"

             " AND BLOOD GROUP IS OF `O" TYPE".

      DISPLAY (3 , 1) UNDER.

      DISPLAY (4 , 1) HEAD.

      DISPLAY (5 , 1) UNDER.

      OPEN INPUT DATAFILE.

      MOVE 6 TO LIN.

      PERFORM Z-PARA UNTIL EOF = "N".

      CLOSE DATAFILE.

      STOP RUN.

   X-PARA.

      DISPLAY (1 , 1) ERASE.

      DISPLAY "ENTER THE NAME OF THE DONAR".

      ACCEPT NAM.

      DISPLAY "ENTER ADDRESS".

      ACCEPT ADS.

      DISPLAY "ENTER AGE".

      ACCEPT AGE.

      DISPLAY "ENTER BLOOD GROUP [A,B,O]".

      ACCEPT BGP.

      WRITE DONAR.

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

      ACCEPT EOF.

   Y-PARA.

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

      DISPLAY (LIN , 6) NAM.

      DISPLAY (LIN , 26) ADS.

      DISPLAY (LIN , 56) AGE.

      DISPLAY (LIN , 70) BGP.

      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.

   Z-PARA.

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

      IF (EOF NOT = "N")

       IF (AGE < 30 AND BGP = "O")

        DISPLAY (LIN , 6) NAM

       DISPLAY (LIN , 26) ADS

       DISPLAY (LIN , 56) AGE

       DISPLAY (LIN , 70) BGP

       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.