Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

Calculate Total percentage Class for each student and store it in output file

Posted By: Hildegarde Miller     Category: Cobol     Views: 7709

Position Desc.
1 - 3 No.
4 - 18 Name.
19 - 22 Cobol.
23 - 26 Nt.
27 - 30 C.
31 - 34 Tc++.

Calculate Total percentage Class (Dist , First)
for each student and output file should contain Each information and also display no name percentage of student having highest marks.

Code for Calculate Total percentage Class for each student and store it in output file in Cobol

       IDENTIFICATION DIVISION.
       PROGRAM-ID. JINESH.

       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT IN-FILE ASSIGN TO DISK
             ORGANIZATION IS LINE SEQUENTIAL.
           SELECT OUT-FILE ASSIGN TO DISK
             ORGANIZATION IS LINE SEQUENTIAL.

       DATA DIVISION.
       FILE SECTION.
       FD IN-FILE
           LABEL RECORDS ARE STANDARD
           VALUE OF FILE-ID IS "IN3.TXT".
       01 IN-REC.
           05 NO-IN      PIC 999.
           05 NAME-IN    PIC X(10).
           05 COBOL-IN   PIC 99V99.
           05 NT-IN      PIC 99V99.
           05 C-IN       PIC 99V99.
           05 TC-IN      PIC 99V99.

       FD OUT-FILE
           LABEL RECORDS ARE STANDARD
           VALUE OF FILE-ID IS "OUT3.TXT".
       01 OUT-REC.
           05 NO-OUT    PIC 999.
           05 FILLER    PIC X(5).
           05 NAME-OUT  PIC X(10).
           05 FILLER    PIC X(5).
           05 TOTAL     PIC 999V99.
           05 FILLER    PIC X(5).
           05 PERCENT   PIC 99V99.
           05 FILLER    PIC X(5).
           05 CLASS     PIC X(6).
       WORKING-STORAGE SECTION.
           77 EOF PIC XXX VALUE 'YES'.
       PROCEDURE DIVISION.
       MAIN-PARA.
           OPEN INPUT  IN-FILE
                OUTPUT OUT-FILE.
           READ IN-FILE AT END MOVE 'NO' TO EOF.
           PERFORM CAL-PARA UNTIL EOF = 'NO'.
           CLOSE IN-FILE.
           CLOSE OUT-FILE.
           STOP RUN.

       CAL-PARA.
           MOVE NO-IN TO NO-OUT.
           MOVE NAME-IN TO NAME-OUT.

           COMPUTE TOTAL = COBOL-IN + NT-IN + C-IN + TC-IN.
           COMPUTE PERCENT = TOTAL / 4.

           IF PERCENT > 71
             MOVE 'DIST' TO CLASS 
           ELSE IF
             PERCENT > 60
             MOVE 'FIRST' TO CLASS
           ELSE 
             MOVE 'SECOND' TO CLASS
           WRITE OUT-REC.
           READ IN-FILE AT END MOVE 'NO' TO EOF.
  
Share: 



Hildegarde Miller
Hildegarde Miller author of Calculate Total percentage Class for each student and store it in output file 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!