Answered step by step
Verified Expert Solution
Question
1 Approved Answer
TASK: You want to develop a Java program that will allow you to keep track of a set of employees. In reviewing your employee list,
TASK: You want to develop a Java program that will allow you to keep track of a set of employees. In reviewing your employee list, you notice that your employees fall into two categories: Salaried and Hourly. The following table shows the information that is stored for each type of employee. Field id Salaried X X X Hourly X X name Data Type int String String String int double title X position salary hourlyRate X X a In this project create three classes named Employee, Salaried and Hourly such that: The Employee class contains all of the fields common to both types of entries in your employee list. The Salaried class is a subclass of Employee and contains only those fields that are specific to the Salaried entries in your employee list. The Hourly class is a subclass of Employee and contains only those fields that are specific to the Hourly entries in your employee list. Each of these classes contains all of the normally expected methods. The normally expected methods are: At least one constructor that is an overload constructor that includes all of the necessary information to create an instance. O A getter and setter (accessor and mutator) method for each instance/class variable A toString() method An equals() method O O O O Create your classes so that you can keep track of the Total number of Employees Total number of Salaried employees Total number of Hourly employees Note that you determine these totals by counting the number of times the respective constructors have been called. O O O Create a fourth class named Client that will be used to test your other classes. In this Client class: This class must include the main method In the main method Create an array named employeeList of type Employee with a length of 10 o Populate the employeeList array with the following records by creating an appropriate instance of either the Salaried or Hourly class for each employee and then add the instance to the array. The employees should be added to the employeeList array in the order that they are listed, i.e. Al should be at index 0, Kelly should be at index 1, etc. 0. A salaried employee named Al who is the Manager and is paid $60,000 per year. 1. An hourly employee named Kelly who is a Hostess and is paid $25.75 per hour. 2. A salaried employee named Peggy who is the CEO and is paid $120,000 per year. 3. An hourly employee named Bud who is a Busboy and is paid $15.00 per hour. 4. An hourly employee named Marcy who is a Server and is paid $10.00 per hour. 5. An hourly employee named Jefferson who is a Cook and is paid $35.00 per hour. Once you have populated the array print out the contents of the array using a for loop. Hint - just use the toString() method to print the contents of an entry. This loop should print out the contents of every entry in the array including the blank (null) entries. a O Now give everyone in the employeeList array a 25% raise. When applying the raises use a loop to step across the array. Your code must dynamically determine the type of employee at each array location by using the instanceof operator (i.e. your code should correctly apply raises regardless of the order in which the employees are entered into the array). After you have given everyone a 25% raise: Print out the contents of the array using a for loop. This time do not print the blank (null) entries. Your code must dynamically determine if an entry is null and not print out the null entries. O 1 o Finally, explicitly test the equals methods for each of your classes. This will require four tests. Show at least one test where the equals() method returns true and one test where the equals() method returns false for the Hourly class. Show at least one test where the equals() method returns true and one test where the equals() method returns false for the Salaried class. 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started