Question: just need to fix the format error with Arik Haversham 1 3 0 0 . 2 5 so that line lines up with the rest
just need to fix the format error with Arik Haversham so that line lines up with the rest as shown in picture
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 fthisfirstName, 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 toor greater than the specified employee.
@Override
public int compareToEmployee other
Compare by last name
int lastNameComparison thislastName.compareTootherlastName;
If last names are the same, compare by first name
if lastNameComparison
int firstNameComparison thisfirstName.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 mainStringargs
Step : Create Employee objects
Employee enew EmployeeHarryBrown;
Employee enew EmployeeNishaNapier;
Employee enew EmployeeHuyenLe;
Employee enew EmployeeArikHaversham;
Employee enew EmployeeNinaLe;
Employee enew EmployeeMarticiaBrown;
Employee enew EmployeeWilliamJones;
Employee enew EmployeeNaquitaJones;
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;
just need to fix the error with Arik Haversham so that line lines up with the rest as shown in 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
