Create an array class for Employee which will reserved 7 elements. The class will have 2 data fields, a constructor and a get method for each field. The employee constructor requires two arguments: an employee number and a salary. You may use any looping statements.
I started it but I don’t know how to finish it:
import java.util.Scanner;
public class Employee {
int [] array= new int [8];
private int empNum;
private double empSal;
void Test1(int e, double s){
empNum = e;
empSal = s;
}
public int getEmpNum(){
return empNum;
}
public double getSalary(){
return empSal;
}
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
System.out.printf("Please enter your employee number:");
int e = sc.nextInt();
System.out.printf("Please enter your salary:");
double s= sc.nextInt();
}
}
Assuming you’ll want 7 employees (at most), don’t care for unique empNum (if you do you can add
equalsTo()overriden function).Also assuming you do all your additions once in the main function, with no special logic.