9A
Complete the class HighTemperatureMinder. The constructor takes an int array as parameter. The array can be any length .
Write these methods:
public double average()
returns the average of the temperatures in the arraypublic int biggestChange()
calculates the biggest difference between two consecutive days. This will be a positive number. If the array is the empty array (length of 0), return 0public boolean theSame(HighTemperatureMinder otherMinder
) returns true if this HighTemperatureMinder contains the same values in the same order as otherMinder. Otherwise returns false. Do not use any of the Arrays class methods. Use loops.For the draft, complete the constructor and the average method.
9B
You are given an Employee class. An Employee has a name and an ArrayList of weekly salaries 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 String getHighestPaid()
which returns the name of the employee with the highest average salary. It should return null if the Staff is empty.public int countOver(double target)
which returns the number of Employees whose average weekly salary to date is over targetA toString method has been provided to aid in testing.
For the draft; finish the constructor and code the add() method.
9C
Complete the class ScoreManager which model the grades for a class on a particular assessment (assignment, quiz, exam). The constructor takes a String name (the name of the assessment ) and an int array of scores in that order. Complete the following methods. They are implemented as stubs. Provide any missing Javadoc in the final only.
public String getName()
gets the namepublic int countTarget(int target)
return the number of times a particular score occurs. public int mode()
return the mode (the value that occurs most often)public int[] letterCounts()
return an array containing the number of A's B's, C's, D's, F'sThere would be a problem in letterCounts if you put the count of A's in index 0, but in the tester I thought it was index 4. To solve this problem, you will define and use these constants
public static final int INDEX_A = 4;
public static final int INDEX_B = 3;
public static final int INDEX_C = 2;
public static final int INDEX_D = 1;
public static final int INDEX_F = 0;
You must use these constants to get full credit. This is a common way to communicate values between parts of an application. Look at the tester to see how I use the constants.
In letterCount, use an if / else if/ else
structure. Do not use unnecessary tests.
For he draft, code instance variables, constructor (which should initialize the instance variables), the getName
and countTarget
method.