Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

NAME: Param Shah

ID: Vu4f2021119
DIV: A
EXPIRNMENT NO : 11

AIM: An employee works in a particular department of an organization. Every


employee has an employee number, name and draws a particular salary. Every
department has a name and a head of department. The head of department is
an employee. Every year a new head of department takes over. Also, every year
an employee is given an annual salary enhancement. Identify and design the
classes for the above description with suitable instance variables and methods.
The classes should be such that they implement information hiding. You must
give logic in support of your design. Also create two objects of each class.

Code:
class Exp11 {

public static void main (String[] args) {


Employee e1= new Employee();
e1.setempdetails(123,"Param Shah",50000);
e1.enhancsal();

HOD h1= new HOD();


h1.setHODdetails(13,"Vedika maam",75000, "I.T");
h1.changeHOD(11," Ganesh sir",75000, "I.T");

}
}

class Employee {
public int emp_no;
public String emp_name;
public int emp_saL;
public double new_saL;
public double inc;

public void setempdetails(int no, String name , int sal){


emp_no=no;
emp_name= name;
emp_saL=sal;
System.out.println("||||||||||||||||||||Employee||||||||||||||||||||");
System.out.println("ID number of the Employee is " + emp_no);
System.out.println("Name of the Employee is " + emp_name);
System.out.println("Salary of the Employee is " + emp_saL);

}
public void enhancsal(){
System.out.println("Previous salary of the Employee "+ emp_name +" is " + emp_saL);
inc =( emp_saL/5);
new_saL= inc + emp_saL;
System.out.println("Enchanced salary of the Employee " + emp_name +" is " + new_saL);
}

class HOD{
public int hod_no;
public String hod_name;
public int hod_saL;
public String hod_dep;

public void setHODdetails(int no, String name , int sal , String dep){
hod_no=no;
hod_name= name;
hod_saL=sal;
hod_dep = dep;
System.out.println("||||||||||||||||||||H.O.D||||||||||||||||||||");
System.out.println("ID number of the Current H.O.D is " + hod_no);
System.out.println("Name of the Current H.O.D is " + hod_name);
System.out.println("Salary of the Current H.O.D is " + hod_saL);
System.out.println("Department of the Current H.O.D is " + hod_dep);

}
public void changeHOD(int no, String name , int sal , String dep){
hod_no=no;
hod_name= name;
hod_saL=sal;
hod_dep=dep;

System.out.println("ID number of the new H.O.D is " + hod_no);


System.out.println("Name of the new H.O.D is " + hod_name);
System.out.println("Salary of the new H.O.D is " + hod_saL);
System.out.println("Department of the new H.O.D is " + hod_dep);

}
OUTPUT:

You might also like