Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

Program to calculate gross salary, deduction, net salary of an employee

Posted By: Verner Fischer     Category: Cobol     Views: 82628

Program to calculate gross salary, deduction, net salary of an employee.

Position Desc.
1 - 3 Emp-No
5 - 14 Emp-Name.
15 - 21 Basic (9(4) V 99).

Consider the condition
Basic Da Hra Ma Pt Pf It.
<1000 5% 2.5% 50 20 8% -
<3000 7.5% 5% 250 60 8% -
<5000 11% 7.5% 500 60 11% 11%

else
25% 11% 700 80 12% 20%.

Calculate
Gross S = Basic + Da + Hra + Ma.
Deduction = Gross S - Pf - Pt - It.
Net Salary = Gross S - Deduction.
Output file should contain all the fields of
input file and calculated Gross S Deduction and Net Salary.

Code for Program to calculate gross salary, deduction, net salary of an employee in Cobol

       IDENTIFICATION DIVISION.
       PROGRAM-ID. ASSIGN-3.

       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT IN3 ASSIGN TO DISK
           ORGANIZATION IS LINE SEQUENTIAL.
           SELECT OUT3 ASSIGN TO DISK
           ORGANIZATION IS LINE SEQUENTIAL.
       DATA DIVISION.
       FILE SECTION.
       FD IN3
          LABEL RECORDS ARE STANDARD
          VALUE OF FILE-ID IS "IN3.TXT".
       01 IN3-REC.
          05 EMPNO-IN PIC 9(3).
          05 EMPNAME-IN PIC X(10).
          05 BASIC-IN PIC 9999V99.
       FD OUT3
          LABEL RECORDS ARE STANDARD
          VALUE OF FILE-ID IS "OUT3.TXT".
       01 OUTREC PIC X(80). 
       WORKING-STORAGE SECTION.

       77 ARE-THERE-MORE-REC PIC XXX VALUE 'YES'.
       77 DA PIC 9(4)V99.
       77 HRA PIC 9(4)V99.
       77 MA PIC 9(4)V99.
       77 PT PIC 9(4)V99.
       77 PF PIC 9(4)V99.
       77 IT PIC 9(4)V99.
      * 77 GS PIC 9(5)V99.
      * 77 DID PIC 9(5)V99.
       01 OUT3-REC.
          05 EMPNO-OUT PIC 9(3).
          05 FILLER PIC X(5).
          05 EMPNAME-OUT PIC X(10).
          05 FILLER PIC X(5).
          05 BASIC-OUT PIC 9(4).99.
          05 FILLER PIC X(5).
          05 GS-OUT PIC 9(5)V99.
          05 FILLER PIC X(5).
          05 DID-OUT PIC 9(5)V99.
          05 FILLER PIC X(5).
          05 NET-SAL PIC 9(5).99.

       01 H1.
          05 STAR PIC X(80) VALUE ALL '*'.

       01 H2.
          05 EMPNO PIC X(5) VALUE "EMPNO".
          05 FILLER PIC X(5).
          05 EMPNAME PIC X(10) VALUE "EMP NAME".
          05 FILLER PIC X(5).
          05 BASIC PIC X(5) VALUE "BASIC".
          05 FILLER PIC X(2).
          05 GS PIC X(15) VALUE "GROSS SALARY".
          05 FILLER PIC X(2).
          05 DID PIC X(10) VALUE "DIDUCTION".
          05 FILLER PIC X(5).
          05 NET PIC X(15) VALUE "NET SALARY".


       PROCEDURE DIVISION.
       MAIN-PARA.
           OPEN INPUT IN3
                OUTPUT OUT3.
                WRITE OUTREC FROM H1.
                WRITE OUTREC FROM H2.
                WRITE OUTREC FROM H1.

           READ IN3
                AT END MOVE 'NO' TO ARE-THERE-MORE-REC.
                PERFORM PARA-1 UNTIL ARE-THERE-MORE-REC = 'NO'.
           CLOSE IN3.
           CLOSE OUT3.
           STOP RUN.
       PARA-1.
           MOVE EMPNO-IN TO EMPNO-OUT.
           MOVE EMPNAME-IN TO EMPNAME-OUT.
           MOVE BASIC-IN TO BASIC-OUT.
           IF BASIC-IN < 1000
              COMPUTE DA = ( BASIC-IN ) * ( 5 / 100 ) 
              COMPUTE HRA = ( BASIC-IN ) * ( 0.025 )
              MOVE 50 TO MA
              MOVE 20 TO PT
              COMPUTE PF = ( BASIC-IN ) * ( 8 / 100 )
              MOVE 0 TO IT

           ELSE IF BASIC-IN < 3000
              COMPUTE DA = ( BASIC-IN ) * ( 0.075 ) 
              COMPUTE HRA = ( BASIC-IN ) * ( 5 / 100 )
              MOVE 250 TO MA
              MOVE 60 TO PT
              COMPUTE PF = ( BASIC-IN ) * ( 8 / 100 )
              MOVE 0 TO IT

           ELSE IF BASIC-IN < 5000
              COMPUTE DA = ( BASIC-IN ) * ( 11 / 100 ) 
              COMPUTE HRA = ( BASIC-IN ) * ( 0.075 )
              MOVE 500 TO MA
              MOVE 60 TO PT
              COMPUTE PF = ( BASIC-IN ) * ( 11 / 100 )
              COMPUTE IT = ( BASIC-IN ) * ( 11 / 100)

           ELSE
              COMPUTE DA = ( BASIC-IN ) * ( 25 / 100 ) 
              COMPUTE HRA = ( BASIC-IN ) * ( 11 / 100 )
              MOVE 700 TO MA
              MOVE 80 TO PT
              COMPUTE PF = ( BASIC-IN ) * ( 12 / 100 )
              COMPUTE IT = ( BASIC-IN ) * ( 20 / 100).

              ADD BASIC-IN DA HRA MA GIVING GS-OUT.
      *        MOVE GS TO GS-OUT.
              ADD PF PT IT GIVING DID-OUT.
      *        MOVE DID TO DID-OUT.
              SUBTRACT DID-OUT FROM GS-OUT GIVING NET-SAL.

              WRITE OUTREC FROM OUT3-REC.
           READ IN3 AT END MOVE 'NO' TO ARE-THERE-MORE-REC.





Input:-
101Shah vipul250000
102Patel Mit 400000
103Shah Ramu 700000
104Dave Teena150000

Output:-
********************************************************************************
EMPNO     EMP NAME       BASIC  GROSS SALARY     DIDUCTION      NET SALARY      
********************************************************************************
101     Shah vipul     2500.00     0306250     0026000     02802.50             
102     Patel Mit      4000.00     0524000     0094000     04300.00             
103     Shah Ramu      7000.00     1022000     0232000     07900.00             
104     Dave Teena     1500.00     0193750     0018000     01757.50             
  
Share: 



Verner Fischer
Verner Fischer author of Program to calculate gross salary, deduction, net salary of an employee is from Frankfurt, Germany.
 
View All Articles

 
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!