Question: Recall the class discussion about object composition. In that discussion we looked at several objects: Date, Time, Name, Employee, and Company. Using the given source

Recall the class discussion about "object composition". In that discussion we looked at
several objects: Date, Time, Name, Employee, and Company. Using the given source code for
these classes, complete the following three methods whose stubs are provided for you in the
Program08.java file.
int findLargestSalary( Employee[] workers )- This method returns the salary of the
worker in the given parameter array who is paid the most. Your method should only require
linear time (i.e., O(n)), since the problem can be solved using a single loop.
int countLeapDay( Employee[] workers )- This method returns the number of workers in
the given parameter array who were born on Leap Day (February 29). Your method should
only require linear time (i.e.,O(n)), since the problem can be solved using a single loop.
int busiestHiringYear( Employee[] workers )- This method returns the year in which the
most number of workers were hired. If there is a tie for the value of this year, then any year
that is busiest may be returned (that is, you can break the tie any way you wish). As always,
we want as efficient a solution as possible. The best strategy for this problem is to first sort
the array of Employees. You want to sort the array based on the hireDate (not alphabetically
by name). Once the array is sorted, then you can do a single loop through the array, locating
each consecutive sequence of array entries that have the same hireDate. You can use the
library method Arrays.sort(workers ), but you will need to add a compareTo(...) method
to the given Employee class. You will also need to edit the header of the Employee class
from:
public class Employee .
to
public class Employee implements Comparable Employee .
You must not change the given Date, Name or Employee classes in any other way. A
Program08.java file is provided for you. The main method in this class creates Employee
arrays, and invokes the methods above. If your class is written correctly then you should
have no error messages when this main method executes. Note that testing can reveal the
presence of errors, but the lack of errors in the testing process does not guarantee that the
code is correct. You may want to add more test cases to the given main method. Upload a
zipfile containing all of the files: Program08.java, Employee.java, Name.java, and Date.java.
You should include YOUR NAME in the comment at the top of every file.source code for program08
/** Program 08
*
* @author PUT YOUR NAME HERE
*/
import java.util.Arrays;
public class Program08
{
public static void main ( String[] args )
{
System.out.println( "Hello world" );
Employee[] people ={
new Employee ( new Name ("bob","doe"), new Date(2,29,1984), new Date(7,2,2010),35_000),
new Employee ( new Name ("alice","evans"),new Date(9,30,1980), new Date(1,25,2016),23_000),
new Employee ( new Name ("ann","lee"), new Date(2,29,1992), new Date(11,12,2019),25_000),
new Employee ( new Name ("sam","kim"), new Date(2,29,1988), new Date(6,2,2018),38_000),
new Employee ( new Name ("jane","lee"), new Date(10,6,1993), new Date(6,12,2018),25_000),
new Employee ( new Name ("ed","smith"), new Date(2,29,1988), new Date(6,2,2018),42_000),
new Employee ( new Name ("ted","jones"), new Date(4,18,1992), new Date(5,22,2016),19_000)
};
Employee[] folks ={
new Employee ( new Name ("bob","doe"), new Date(2,14,1984),new Date(7,2,2021),53_000),
new Employee ( new Name ("alice","evans"),new Date(9,30,1980),new Date(1,25,2015),23_000),
new Employee ( new Name ("ann","lee"), new Date(1,7,1992), new Date(11,12,2016),25_000),
new Employee ( new Name ("sam","kim"), new Date(7,4,1988), new Date(6,2,2019),38_000),
new Employee ( new Name ("jane","lee"), new Date(10,6,1993),new Date(6,12,2015),25_000),
new Employee ( new Name ("ed","smith"), new Date(6,12,1988),new Date(6,2,2008),42_000),
new Employee ( new Name ("ted","jones"), new Date(4,18,1992),new Date(5,22,2019),19_000)
};
Employee[] individual ={
new Employee ( new Name ("alice","evans"), new Date(2,29,1980), new Date(2,25,2015),23_000),
};
try {
if ( findLargestSalary ( people )!=42000)
System.out.println( "findLargestSalary fails on output 42,000");
} catch ( RuntimeException trouble ){
System.out.println ( "Error in findLargestSalary method" );
}
try {
if ( findLargestSalary ( folks )!=53_000)
System.out.println( "findLargestSalary fails on output 53,000");
} catch ( RuntimeException trouble ){
System.out.println ( "Error in findLargestSalary method" );
}
try {
if ( findLargestSalary ( individual )!=23_000)
System.out.println( "findLargestSalary fails on output 23,000");
} catch ( RuntimeException trouble ){
System.out.println ( "Error in findL
Recall the class discussion about "object

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 Programming Questions!