IDENTIFICATION DIVISION.
PROGRAM-ID. TRR.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INFILE ASSIGN TO DISK
ORGANIZATION IS LINE SEQUENTIAL.
SELECT OUTFILE ASSIGN TO DISK
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD INFILE
LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID IS "IN.TXT".
01 INREC.
02 SNO PIC X(5).
02 SNAME PIC X(15).
02 QA PIC 9(2).
02 QM PIC 9(2).
FD OUTFILE
LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID IS "OUT.TXT".
01 OUTREC PIC X(80).
WORKING-STORAGE SECTION.
77 P PIC 9(3)V99.
77 PC PIC 9(3)V99.
77 GRADE PIC X(3).
77 CON PIC X(1).
01 H1.
02 F PIC X(25) VALUE SPACES.
02 F PIC X(25) VALUE "TEST RESULT REPORT".
01 H2.
02 F PIC X(7) VALUE "SNAME".
02 F PIC X(6) VALUE SPACES.
02 F PIC X(10) VALUE "SNAME".
02 F PIC X(6) VALUE SPACES.
02 F PIC X(10) VALUE "QASKED".
02 F PIC X(6) VALUE SPACES.
02 F PIC X(10) VALUE "QMISSED".
02 F PIC X(6) VALUE SPACES.
02 F PIC X(8) VALUE "PERCENT".
02 F PIC X(6) VALUE SPACES.
02 F PIC X(6) VALUE "GRADE".
01 O-REC.
02 ONO PIC X(7) VALUE SPACES.
02 F PIC X(6) VALUE SPACES.
02 ONAME PIC X(10) VALUE SPACES.
02 F PIC X(6) VALUE SPACES.
02 OQA PIC X(10) VALUE SPACES.
02 F PIC X(6) VALUE SPACES.
02 OQM PIC X(10) VALUE SPACES.
02 F PIC X(6) VALUE SPACES.
02 OPC PIC Z9(3).
02 F PIC X(6) VALUE SPACES.
02 OGRADE PIC X(6) VALUE SPACES.
01 H4.
02 F PIC X(80) VALUE ALL "*".
PROCEDURE DIVISION.
CON-PARA.
OPEN OUTPUT INFILE.
INPUT-PARA.
DISPLAY "ENTER THE STU NO"
ACCEPT SNO.
DISPLAY "ENTER THE STU NAME"
ACCEPT SNAME.
DISPLAY "ENTER THE QASKED"
ACCEPT QA.
DISPLAY "ENTER THE QMISSED"
ACCEPT QM.
WRITE INREC.
DISPLAY "Y/N".
ACCEPT CON.
PERFORM INPUT-PARA UNTIL CON = "N".
INCLOSEPARA.
CLOSE INFILE.
OUTPUT-PARA.
OPEN INPUT INFILE OUTPUT OUTFILE.
WRITE OUTREC FROM H1.
WRITE OUTREC FROM H4.
WRITE OUTREC FROM H2.
WRITE OUTREC FROM H4.
RESULT-PARA.
READ INFILE AT END GO TO CLOSE-PARA.
COMPUTE P = QA - QM.
COMPUTE PC = (P / QA) * 100.
IF PC > 89 AND PC < 101
MOVE "A" TO GRADE
ELSE IF PC > 79 AND PC < 91
MOVE "B" TO GRADE
ELSE IF PC > 69 AND PC < 81
MOVE "C" TO GRADE
ELSE IF PC > 59 AND PC < 71
MOVE "D" TO GRADE
ELSE
MOVE "E" TO GRADE.
MOVE SNO TO ONO.
MOVE SNAME TO ONAME.
MOVE QA TO OQA.
MOVE QM TO OQM.
MOVE PC TO OPC.
MOVE GRADE TO OGRADE.
WRITE OUTREC FROM O-REC.
GO TO RESULT-PARA.
CLOSE-PARA.
CLOSE INFILE, OUTFILE.
STOP RUN.
PROGRAM-ID. TRR.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT INFILE ASSIGN TO DISK
ORGANIZATION IS LINE SEQUENTIAL.
SELECT OUTFILE ASSIGN TO DISK
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD INFILE
LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID IS "IN.TXT".
01 INREC.
02 SNO PIC X(5).
02 SNAME PIC X(15).
02 QA PIC 9(2).
02 QM PIC 9(2).
FD OUTFILE
LABEL RECORDS ARE STANDARD
VALUE OF FILE-ID IS "OUT.TXT".
01 OUTREC PIC X(80).
WORKING-STORAGE SECTION.
77 P PIC 9(3)V99.
77 PC PIC 9(3)V99.
77 GRADE PIC X(3).
77 CON PIC X(1).
01 H1.
02 F PIC X(25) VALUE SPACES.
02 F PIC X(25) VALUE "TEST RESULT REPORT".
01 H2.
02 F PIC X(7) VALUE "SNAME".
02 F PIC X(6) VALUE SPACES.
02 F PIC X(10) VALUE "SNAME".
02 F PIC X(6) VALUE SPACES.
02 F PIC X(10) VALUE "QASKED".
02 F PIC X(6) VALUE SPACES.
02 F PIC X(10) VALUE "QMISSED".
02 F PIC X(6) VALUE SPACES.
02 F PIC X(8) VALUE "PERCENT".
02 F PIC X(6) VALUE SPACES.
02 F PIC X(6) VALUE "GRADE".
01 O-REC.
02 ONO PIC X(7) VALUE SPACES.
02 F PIC X(6) VALUE SPACES.
02 ONAME PIC X(10) VALUE SPACES.
02 F PIC X(6) VALUE SPACES.
02 OQA PIC X(10) VALUE SPACES.
02 F PIC X(6) VALUE SPACES.
02 OQM PIC X(10) VALUE SPACES.
02 F PIC X(6) VALUE SPACES.
02 OPC PIC Z9(3).
02 F PIC X(6) VALUE SPACES.
02 OGRADE PIC X(6) VALUE SPACES.
01 H4.
02 F PIC X(80) VALUE ALL "*".
PROCEDURE DIVISION.
CON-PARA.
OPEN OUTPUT INFILE.
INPUT-PARA.
DISPLAY "ENTER THE STU NO"
ACCEPT SNO.
DISPLAY "ENTER THE STU NAME"
ACCEPT SNAME.
DISPLAY "ENTER THE QASKED"
ACCEPT QA.
DISPLAY "ENTER THE QMISSED"
ACCEPT QM.
WRITE INREC.
DISPLAY "Y/N".
ACCEPT CON.
PERFORM INPUT-PARA UNTIL CON = "N".
INCLOSEPARA.
CLOSE INFILE.
OUTPUT-PARA.
OPEN INPUT INFILE OUTPUT OUTFILE.
WRITE OUTREC FROM H1.
WRITE OUTREC FROM H4.
WRITE OUTREC FROM H2.
WRITE OUTREC FROM H4.
RESULT-PARA.
READ INFILE AT END GO TO CLOSE-PARA.
COMPUTE P = QA - QM.
COMPUTE PC = (P / QA) * 100.
IF PC > 89 AND PC < 101
MOVE "A" TO GRADE
ELSE IF PC > 79 AND PC < 91
MOVE "B" TO GRADE
ELSE IF PC > 69 AND PC < 81
MOVE "C" TO GRADE
ELSE IF PC > 59 AND PC < 71
MOVE "D" TO GRADE
ELSE
MOVE "E" TO GRADE.
MOVE SNO TO ONO.
MOVE SNAME TO ONAME.
MOVE QA TO OQA.
MOVE QM TO OQM.
MOVE PC TO OPC.
MOVE GRADE TO OGRADE.
WRITE OUTREC FROM O-REC.
GO TO RESULT-PARA.
CLOSE-PARA.
CLOSE INFILE, OUTFILE.
STOP RUN.
No comments:
Post a Comment