Question: Employee.Java: Create a class named Employee that contains the employees id, name, and salary. Update this class with toString() method, that combines the values into

Employee.Java: Create a class named Employee that contains the employees id, name, and salary. Update this class with toString() method, that combines the values into one string in a nice format (e.g., John is an Employee with ID of 123 and salary 80000$)

public class Employee {

public int ID;

public String Name;

public Float Salary;

//constructor

Employee (int id, String NM, Float SL){

ID = id;

Name = NM;

Salary = SL;

}

}

Engine.Java: this is your main class and structured as follows:

public class Engine {

public static void main(String[] args)

//Step1: create an array of employees

//Step2: read input and Create/add employees to the array accordingly

//Step3: from the array, generate a final report

}

}

For Step1, you may create a fixed sized array (Array) or a dynamic sized array (ArrayList recommended)

For Step2, you take input, create an Employee object, and finally add the employee to the array (of step1). To take input, there are two options choose one according to which method(s) discussed in your programming classes (you should be able to do the two).

Option1: you create a text file somewhere on your computer, and is structured with an employee record per line. Each record (line) is composed of the employees ID, followed by the name, and then the salary (comma separated). You will read the file line by line. For each line, divide it to get the values (ID, name, and salary), create an Employee object with the retrieved values, and finally add the employee to the array. (Note, the values you read from the file are strings and your Employee constructor accepts integer for ID and float for Salary).

Here is an example of the structure, you will fill the fill with records manually:

15, John, 80500.54

48, Olivia, 90200.64 .. ..

20, Adam, 100500.00

Option2: you accept user inputs from the keyboard, take the input and create an employee object then finally add the new object to the array. In both options, you may consider information for 5 employees.

For Step3, generate a statistical report (as print statements or as a text file) given the available employees in the array. The report, structured the way you prefer, contains:

1- nicely printable format for the records (use the toString() function) you may also sort the records with respect to the ID.

2- the number of employees and the average salary

3- the employee with the minimum salary, and the employee with the maximum salary.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!