FALSE

Page Nav

HIDE

Grid

GRID_STYLE

COBOL Program to compute salary of employees

         IDENTIFICATION DIVISION.                 PROGRAM-ID. Q7.         ENVIRONMENT DIVISION.          CONFIGURATION SECTION.         ...

         IDENTIFICATION DIVISION.
                PROGRAM-ID. Q7.
        ENVIRONMENT DIVISION.
         CONFIGURATION SECTION.
                SOURCE-COMPUTER. IBM PC.
                OBJECT-COMPUTER. IBM PC.
         INPUT-OUTPUT SECTION.
          SELECT IN-FILE ASSIGN TO "Q7IN.DAT" ORGANIZATION   IS
           LINE SEQUENTIAL.
          SELECT OUT-FILE ASSIGN TO "Q7OUT.TXT".
                      
        DATA DIVISION.
          FILE SECTION.
        FD    IN-FILE.
        01    IN-REC.
                02      IN-WORKER-CODE PIC 9999.
                02      IN-HRS-WORKED  PIC 999.
                02      IN-WAGE-RATE PIC 99V99.
        FD    OUT-FILE.
        01    OUT-REC PIC X(80).


          WORKING-STORAGE SECTION.
        77    EOF PIC X VALUE "N".
        77    HEADING1 PIC X(80) VALUE ALL  "-".
        01    OUT-FORMAT.
                02  OUT-WORKER-CODE PIC 9999.
                02  F PIC X(10) VALUE SPACES.
                02  OUT-HRS-WORKED PIC Z99.
                02  F PIC X(10) VALUE SPACES.
                02  OUT-WAGE-RATE PIC *9.99.
                02  F PIC X(10) VALUE SPACES.
                02  OUT-TOTAL-SALARY PIC ****.**.
                              
        PROCEDURE DIVISION.
        MAIN-PARA.
        OPEN INPUT IN-FILE OUTPUT OUT-FILE.
        MOVE HEADING1 TO OUT-REC.
        WRITE OUT-REC BEFORE ADVANCING 1 LINE.
        MOVE "                                WEEKLY WAGES REPORT"
                TO OUT-REC.
        WRITE OUT-REC BEFORE ADVANCING 1 LINE  .
        MOVE HEADING1 TO OUT-REC.            
        WRITE OUT-REC BEFORE ADVANCING 1 LINE.
        MOVE "WORKER CODE | HRS. WORKED | WAGE RATE | NET SALARY(RS.) "
         TO OUT-REC.
        WRITE OUT-REC BEFORE ADVANCING 1 LINE.
      
        READ IN-FILE AT END MOVE "Y" TO EOF.
        PERFORM CALC-PARA UNTIL EOF = "Y".
        DISPLAY "THE DETAILS HAVE  BEEN WRITTEN TO FILE Q7OUT.DAT".
        CLOSE IN-FILE , OUT-FILE.
        STOP RUN.

        CALC-PARA.
        IF IN-HRS-WORKED > 42
                COMPUTE OUT-TOTAL-SALARY = 42 * IN-WAGE-RATE
                   + ( IN-HRS-WORKED - 42 ) * 2 * IN-WAGE-RATE
        ELSE
                COMPUTE OUT-TOTAL-SALARY = IN-HRS-WORKED * IN-WAGE-RATE.
        MOVE IN-WORKER-CODE  TO OUT-WORKER-CODE.
        MOVE IN-HRS-WORKED TO OUT-HRS-WORKED.
        MOVE IN-WAGE-RATE TO OUT-WAGE-RATE.
        MOVE OUT-FORMAT TO OUT-REC.
        WRITE OUT-REC BEFORE ADVANCING 1 LINE.

        READ IN-FILE AT END MOVE "Y" TO EOF.

No comments