Question: Create the class Employee with int id , String name, double salary and int numberOfDependents as private fields. Override the toString method to print an
Create the class Employee with int id String name, double salary and int numberOfDependents as private fields. Override the toString method to print an employee in the format idname,net salary where:
Net salary salarynumberOfDependent salary
Add the constructor public Employee String name, double salary, int numberOfDependent to set this.name, this.salaray and this.numberOfDependent using the corresponding parameters, and set the id to be the same of the ascii codes of the string: name.toUpperCase Here toUpperCase is the Strings method that returns the string of all of the characters in in upper case. Consequently, scotty Riter and scottY riTer are the same. You may change the names to be all in capital lettersNames are not to be hanged to upper case.
The goal of this is to create a special linked list to store the employees. We seek to implement a structure that can be pictured as:
see attached picture
The dots represent null references of type Employee. Each node of company should contain two
references that you may call next and below, in addition to Employee e The picture above shows the
names of the employees only, but your code should store an object of type employee, not just the
name That is:
class Node
private Employee e;
private Node next;
private Node below;
One way to construct such linked list, we use:
class LinkedList
Node company;
public LinkedList
company null;
Note that the employees Aidan Jones, Nadia Jones and Naadi Jones have the same id collision case
here and that is why you see Nadia Jones and Naadi Jones are inserted to the sublinked list whose
head if the below reference of Aidan Jones.
So if we add Dean Ali, the list above becomes:
see attached picture
The names of the list above could have been added in this order:
Kim Oz Rim Oz Dane Ali, Aidan Jones, Nadia Jones, Ed Renu, Naddi Jones and Dean Ali.
Your code should provide the code that allows to:
Print all the employees idname,net salary
Add a new employee
Search for an employee by name.
Find the highest net salary Just the number
Delete an employee by name
The Driver class DriverClassjava is provided below. Dont change anything in the DriverClass.java
public class DriverClass
public static void mainString args
LinkedList list new LinkedList;
list.addNewEmployeenew Employee Kim Oz;
list.addNewEmployeenew Employee Rim Oz;
list.addNewEmployeenew Employee Dane Ali ;
list.addNewEmployeenew Employee Aidan Jones ;
list.addNewEmployeenew Employee Nadia Jones", ;
list.addNewEmployeenew Employee Ed Renu", ;
list.addNewEmployeenew Employee Naadi Jones", ;
The TAs may use less or more names.
list.printAllEmployees;
System.out.printlnThe highest net salary list.highestNetSalary;
list.deleteEmployeeByNameRim Oz;
list.deleteEmployeeByNameNadia Jones";
System.out.println list.searchByNameGary D Richardson";
list.printAllEmployees;
end of DriverClass
class LinkedList
Node company;
public LinkedList
company null;
public void printAllEmployees
public void addNewEmployee Employee e
public boolean searchByName String name
public double highestNetSalary
public void deleteEmployeeByName String name
class Employee
private String name; Keep these fields private!
private int id;
private int numberOfDependent;
private double salary;
@Override
public String toString
return ;
class Node
private Employee e; Keep these fields private!
private Node next;
private Node below;
THE OUTPUT SHOULD LOOK LIKE WHATS IN THE PICTURE
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
