Question: please help fix the format error with Arik Haversham 1 3 0 0 . 2 5 so that everything lines up with the rest everything
please help fix the format error with Arik Haversham so that everything lines up with the rest everything thing i do affects them all
Employee class representing an employee with a first name, last name, and monthly salary.
This class includes methods for getting and setting these fields and
for representing the employee as a formatted string.
It also implements the Comparable interface to compare employees.
@author
@version
public class Employee implements Comparable
private String firstName;
private String lastName;
private double monthlySalary;
public EmployeeString firstName, String lastName, double monthlySalary
this.firstName firstName;
this.lastName lastName;
this.monthlySalary monthlySalary monthlySalary : ;
public void setFirstNameString firstName
this.firstName firstName;
public void setLastNameString lastName
this.lastName lastName;
public void setMonthlySalarydouble monthlySalary
if monthlySalary
this.monthlySalary monthlySalary;
public String getFirstName
return this.firstName;
public String getLastName
return this.lastName;
public double getMonthlySalary
return this.monthlySalary;
@Override
public String toString
return String.formats s f this.firstName, this.lastName, this.monthlySalary;
public double getYearlySalaryWithIncrease
return this.monthlySalary ;
Compares employees first by last name, then by first name, and finally by monthly salary.
@param other The other employee to compare against.
@return A negative integer, zero, or a positive integer if this employee is less than, equal to or greater than the specified employee.
@Override
public int compareToEmployee other
Compare by last name
int lastNameComparison this.lastName.compareTootherlastName;
If last names are the same, compare by first name
if lastNameComparison
int firstNameComparison this.firstName.compareTootherfirstName;
If first names are the same, compare by monthly salary
if firstNameComparison
return Double.comparethismonthlySalary, other.monthlySalary;
return firstNameComparison;
return lastNameComparison;
import java.util.;
public class EmployeeComparableDemo
public static void mainString args
Step : Create Employee objects
Employee e new EmployeeHarry "Brown", ;
Employee e new EmployeeNisha "Napier", ;
Employee e new EmployeeHuyenLe;
Employee e new EmployeeArik "Haversham", ;
Employee e new EmployeeNinaLe;
Employee e new EmployeeMarticia "Brown", ;
Employee e new EmployeeWilliam "Jones", ;
Employee e new EmployeeNaquita "Jones", ;
Step : Create ArrayList and add employees
ArrayList employees new ArrayList;
employees.adde;
employees.adde;
employees.adde;
employees.adde;
employees.adde;
employees.adde;
employees.adde;
employees.adde;
Step : Print the unsorted list
System.out.printlnUnsorted original list: ;
System.out.println;
for Employee e : employees
System.out.printlne;
Step : Sort the employees using Collections.sort
Collections.sortemployees;
Step : Print the sorted list
System.out.println
Sorted list by last name, first name, then Salary: ;
System.out.println;
for Employee e : employees
System.out.printlne;
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
