0% found this document useful (0 votes)
8 views

practical 4.2[1].pdf

The document outlines a Java programming exercise focused on creating an employee management system. It involves defining an employee class with attributes such as employee code, name, designation, and basic pay, along with methods to calculate HRA, DA, and total pay. The main method creates instances for three employees and displays their calculated compensation details.

Uploaded by

digantmalviya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

practical 4.2[1].pdf

The document outlines a Java programming exercise focused on creating an employee management system. It involves defining an employee class with attributes such as employee code, name, designation, and basic pay, along with methods to calculate HRA, DA, and total pay. The main method creates instances for three employees and displays their calculated compensation details.

Uploaded by

digantmalviya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Core Java Programming (CE0421)

Practical 4.2: The employee list for a company contains employee


code, name, designation and basic pay. The employee is given HRA of
10% of the basic and DA of 45% of the basic pay. The total pay of the
employee is calculated as Basic pay+ HRA+ DA. Write a class to define
the details of the employee. Write a constructor assign the required
initial values. Add a method to calculate HRA, DA and Total pay and
print them out. Write another class with a main method. Create objects
for three different employees and calculate the HRA, DA and total pay.

Code:
import java.util.*;
public class company{
public int emp_code;
public String emp_name;
public String emp_des;
public double payout;
public company(int emp_code, String emp_name, String emp_des, double payout){

this.emp_code = emp_code;
this.emp_name = emp_name;
this.emp_des = emp_des;
this.payout = payout;
}
public double basic_HRA(){
return 0.10 * payout;
}
public double calculateDA(){
return 0.45 * payout;
}
public double calculateTotalPay(){
return payout + basic_HRA() + calculateDA();
}
public void display(){

System.out.println("Code of the Employee is = " + emp_code);


System.out.println("Name of the Employee is = " + emp_name);
System.out.println("Designation of the Employee is = " + emp_des);
System.out.println("Payout of the Employee is = " + payout);
System.out.println("The salary of the HRA = " + basic_HRA());
System.out.println("The salary of the DA = " + calculateDA());
System.out.println("The salary of the Total_payout = " +

calculateTotalPay());

System.out.println();

IU2341230387 B.Tech CSE-D1 15


Core Java Programming (CE0421)

}
public static void main(String [] args){
company emp1 = new company(101, "Himanshu Mali", "Founder",100000000);
company emp2 = new company(102, "Hello India", "CEO", 1000000);
company emp3 = new company(103, "Bye India", "HR Manager", 100000);
emp1.display();
emp2.display();
emp3.display();
}
}

Output:

IU2341230387 B.Tech CSE-D1 16

You might also like