- Java

Java program to compute employee's net salary,HRA,DA and GS

In this article let’s learn how to calculate the net salary of an employee by considering the parameters called HRA(House rent allowance),DA(Dearness allowance),GS (Gross salary)and income tax. Let us assume some parameters.
HRA=10% of basic salary
DA=73% of basic salary
GS=basic salary+DA+HRA
Income tax=30% of gross salary
net salary= GS-income taxAlgorithm:
1)Start
2)Take the input from the user as employee name,id and basic salary
3)Calculate the the above parameters DA,HRA,GS,income tax and net salary
4)Display the output
5)Stop

Code goes here:

import java.util.*;
class employee
{
     private String employeid;
     private String empname;
     private int basicsalary,HRA,DA,GS,incometax,netsalary;
     public void read()
     {
        Scanner scan= new Scanner(System.in);
        System.out.println("Enter the employee id");//taking all the inputs from the user
        employeid=scan.next();
        System.out.println("Enter the employee name");
        empname=scan.next();
        System.out.println("Enter the basic salary of an employee");
        basicsalary=scan.nextInt();
        calculate();
     }
     public void calculate()  //calculating all the parameters
     {
        HRA=(10/100)*basicsalary;
        DA=(73/100)*basicsalary;
        GS=basicsalary+DA+HRA;
        incometax=(30/100)*GS;
        netsalary=GS-incometax;
     }
     public void display()  //displaying the calculating parameters
     {
        System.out.println("Employeeid  :  "+employeid+"n"+"Employename  :  "+empname+"n"+"Employee basic salary :  "+basicsalary+"n"+"HRA  :  "+HRA+"n"+"DA  :  "+DA+"n"+"GS  :  "+GS+"n"+"Incometax  :  "+incometax+"n"+"netsalary  :  "+netsalary);
     }
 
}
class main //main function
{
     public static void main(String args[])
     {
         employee employeobj=new employee();
         employeobj.read(); //calling read function
         employeobj.display(); //calling display function
     }
}

Have a nice day.Thank you visit again

Leave a Reply