suppose ypu are working on defining a new class called Employee. complete the fo
ID: 3821271 • Letter: S
Question
suppose ypu are working on defining a new class called Employee. complete the following:
you will have to decide which attributes should be class-level and which attributes will be instance-level.
-nextEmpID #hold the last employee id that was assigned
-empID
-empNmae
-number of employees whose salary exceeds the averageSalary
-empSalary
-averageSalary of 10000
remember that every time an object of type Employee is instantiated, you will need to update some of the class-level attributes.NOTE: do NOT writte getters or setters or other methods.
just provide:
-the code that implements and maintain any class-level attributes correctly
-the constructor method
Explanation / Answer
Employee.java
public class Employee {
private static int nextEmpID ;
private int empID;
private String empName;
private double empSalary;
private static int averageSalary = 10000;
private static int numberOfEmployee;
public Employee(int empID,String empName, double empSalary ){
this.empID = nextEmpID;
this.nextEmpID =empID;
this.empName= empName;
this.empSalary= empSalary;
if(averageSalary > 10000) {
numberOfEmployee++;
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.