Download - ps3

Transcript
Page 1: ps3

class Employee {

private int employeeId;private String employeeName;private double basicSalary;private double hra;private double medical;private double pf;private double pt;private double netSalary;private double grossSalary;static int count;

public Employee(){

employeeName="Unknown";basicSalary=hra=medical=pf=pt=netSalary=grossSalary=0;

}

public Employee(String n,double b,double m){

employeeName=n;basicSalary=b;medical=m;double pt=200;

}

public void printEmployee(){

count++; employeeId=count;

double hra=0.5*basicSalary;double pf=0.12*basicSalary;double grossSalary=basicSalary+hra+medical;double netSalary=grossSalary-(pt+pf);

System.out.println("Employee Id:"+employeeId+"\nEmployee Name:"+employeeName+"\nSalary:Rs"+basicSalary+"\nHRA:Rs"+hra+"\nMedical:Rs"+medical+"\nPF:Rs"+pf+"\nPT=Rs"+pt+"\nNet Salary:Rs"+netSalary+"\nGross Salary:Rs"+grossSalary);

}

}

Page 2: ps3

class Test_Employee {

public static void main(String[] args) {

Employee e1=new Employee();Employee e2=new Employee("Abhinav",25000,5000);

Employee e3=new Employee("Priya",30000,5000);e2.printEmployee();e3.printEmployee();e1.printEmployee();

}}