-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployee.java
More file actions
78 lines (60 loc) · 1.55 KB
/
Copy pathEmployee.java
File metadata and controls
78 lines (60 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
public class Employee {
private String empName;
private double salary;
private int empId;
public static int empInit;
public static double totalSalary;
public static double avgSalary;
public static int empCount;
static {
empInit = 101;
totalSalary = 0;
empCount = 0;
}
public Employee() {
empName = "Cyber";
salary = 99999.00;
empId = empInit++;
empCount++;
}
public Employee(String empName, double salary) {
this.empName = empName;
this.salary = salary;
this.empId = empInit++;
totalSalary += salary;
empCount++;
}
public void setempName(String empName) {
this.empName = empName;
}
public void setsalary(double salary) {
this.salary = salary;
}
public void setempId(int empId) {
this.empId = empId;
}
public String getempName() {
return empName;
}
public double getsalary() {
return salary;
}
public int getempId() {
return empId;
}
public static void calculateAvgSal() {
System.out.println("Total Salary Of " + empCount + " Employee is " + totalSalary + ".");
System.out.println("----------------------------------------------");
avgSalary = totalSalary / empCount;
System.out.println("Average salary of " + empCount + " Employees is " + avgSalary + ".");
}
public void displayDetails() {
System.out.println("Employee Name:" + empName + ".");
System.out.println("Employee Salary:" + salary + ".");
System.out.println("Employee Id:" + empId + ".");
}
@Override
public String toString() {
return "Employee [EmpName=" + empName + ", Salary=" + salary + ", EmpId=" + empId + "].";
}
}