9A
You are given an Employee
class. An Employee has a name and an ArrayList of weekly salaries (doubles) to date as instance variables. You will complete the Staff class which manages Employee objects. The Staff
class is started for you. It contains a constructor that initializes the instance variable to an empty ArrayList of Employees. It has an add method for adding an Employees to the Staff.
You are to write a constructor and methods
public Staff()
You will need to initialize the ArrayList<Employee>public void add(Employee e)
adds the Employee to this Staffpublic int getCount(double target)
Gets the number of employees whose average salary is less than or equal to the targetpublic ArrayList<String> names()
gets an ArrayList containing the names of all the employeesA toString
method has been provided to aid in testing.
For the draft; finish the constructor and code the add()
method.
9B
Write a class SeaLevelUtil
. It has a constructor takes an int array as parameter. The array can be any length .
Write these methods:
public double average()
returns the average of the sea levels in the array. public int maxDifference()
returns the difference between the highest and lowest points in this SeaLevelUtil
as a positive numberpublic int[] copy()
returns a copy of the array of sea levels. Be sure to make a copy. Do not use any of the Arrays class methods. Use loops.For the draft, provide the instance variable and the constructor. Implement the other methods as stubs. Provide Javadoc. Remember that the code will compile and run but the answers are not correct.
9C
Write a class called SalaryStatistics. The constructor will take two parameters: The string name of the company and an int array of the annual salaries at this company. Call the name of the company companyName and the name of the int[] salaries. This class is for statistical calculations and so the names of the employees are not given. For simplicity, the salaries are integers
The class has these constructor and methods
public String companyName()
Gets this name of the company paying these salaries. Providedpublic double average()
Gets the average of the salaries. Providedpublic int max()
Gets the maximum salarypublic int min()
Gets the minimum salarypublic double standardDeviation()
the standard deviation for the data set of salaries (use the average method). Do not use any library methods except those in Math class.public double minPercentOfMax()
finds what percent the lowest salary in the company is of the highest percentHere is an explanation and formula for standard deviation: https://www.mathsisfun.com/data/standard-deviation-formulas.html
For the draft, finish the constructor and provide stubs for the remaining methods. Provide javadoc