Saturday, 1 March 2014

COBOL program to implement Screen Section concept.



COBOL program to implement Screen Section concept.

PRORGAM:
       IDENTIFICATION DIVISION.
       PROGRAM-ID SCREEN.
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT STD-FILE ASSIGN TO DISK
           ORGANIZATION IS LINE SEQUENTIAL.
       DATA DIVISION.
       FILE SECTION.
       FD STD-FILE
           LABEL RECORDS ARE STANDRAD
           VALUE OFFILE-FD IS "OUT.DAT".
           DATA RECORD IS OUT-REC.
       01 OUT-REC.
           02 STD-ID PIC X(14).
           02 SNAME PIC X(20).
           02 BRANCH PIC X(4).
           02 MARKS1 PIC 9(3).
           02 MARKS2 PIC 9(3).
           02 MARKS3 PIC 9(3).
           02 COMP-PER PIC 99.99.
       WORKING-STORAGE SECTION.
           77 EOF PIC X VALUE 'N'.
           77 CH PIC X VALUE 'N'.
       SCREEN SECTION.
       01 SCR1.
           02 BLANK SCREEN.
           02 LINE 02 COLUMN 10 VALUE 'STUDENT-ID'.
           02 LINE 02 COLUMN 30 PIC X(4) TO STD-ID.
           02 LINE 04 COLUMN 10 VALUE 'NAME'.
           02 LINE 04 COLUMN 30 PIC X(20) TO SNAME.
           02 LINE 06 COLUMN 10 VALUE 'BRANCH'.
           02 LINE 06 COLUMN 30 PIC X(4) TO BRANCH.
           02 LINE 08 COLUMN 10 VALUE 'MARKS1'.
           02 LINE 08 COLUMN 30 PIC VALUE M'MARKS1'.
           02 LINE 10 COLUMN 10 VALUE MARKS2.
           02 LINE 10 COLUMN 30 PIC 9(3) TO MARKS2.
           02 LINE 12 COLUMN 10 VALUE 'MARKS3'.
           02 LINE 12 COLUMN 30 PIC 9(3) TO MARKS3.
       01 SCR2.
           02 BLANK SCREEN
           02 LINE 02 COLUMN 20 VALUE '**' HIGHLIGHTBLANK.
           02 LINE 02 COLUMN 23 VALUE 'STUDENT' HIGHLIGHTBLANK.
           02 LINE 02 COLUMN 31 VALUE 'RECORDS' HIGHLIGHTBLANK.
           02 LINE 02 COLUMN 38 VALUE '**' HIGHLIGHTBLANK.
           02 LINE 04 COLUMN 02 VALUE 'STUDENT-ID'.
           02 LINE 04 COLUMN 17 VALUE 'NAME'.
           02 LINE 04 COLUMN 28 VALUE 'BRANCH'.
           02 LINE 04 COLUMN 35 VALUE 'MARKS1'.
           02 LINE 04 COLUMN 45 VALULE 'MARKS2'.
           02 LINE 04 COLUMN 52 VALUE 'MARKS3'.
           02 LINE COLUMN 62 VALUE 'PERCENTAGE'.
       PROCEDURE DIVISION.
       MAIN-PARA.
           OPEN OUTPUT STD-FILE.
           PERFORM ACCEPT-PARA UNTIL CH='N'.
           CLOSE STD-FILE.
           PEN INPUT STD-FILE.
           DISPLAY SCR2.   F
           READ STD-FILE AT END
           MOVE 'Y' TO EOF.
           MOVE 6 TO LIN
           PERFORM DISP-PARA UNTIL EOF='Y'.
           CLOSE STD-FILE.
           STOP RUN.
       ACCEPT-PARA.
           DISPLAY ( 1 1 )ERASE.
           DISPLAY SCR1.
           ACCEPT SCR1.
           COMPUTE CUM-PER = ( MARKS1 + MARKS2 + MARKS3 )/3.
           WRITE OUT-REC.
           DISPLAY ( 14, 10 ) 'DO U WANT TO INPUT MORE RECORDS ( Y / N )'.
           ACEPT CH.
       DISP-PARA.
           MOVE 4 TO COL.
           DISPLAY ( LIN, COL ) STD-ID.
           ADD 1 1 TO C OL.
           DISPLAY ( LIN, COL ) BRANCH
           ADD 8 TO COL.
           DISPLAY ( LIN, COL ) MARKS1
           ADD 9 TO COL.
           DISPLAY ( LIN, COL ) MARKS2.
           ADD 9 TO COL.
           DISPLAY ( LIN, COL ) MARKS3.
           ADD 9 TO COL.
           DISPLAY ( LIN, COL ) FCUM-PER.
           ADD 1 TO LIN.
           READ STD-FILE AT END.
           MOVE 'Y' TO EOF.

No comments: