Question: HERE IS THE CODE WE ARE GIVEN TO START WITH. public class MaxTemp{ /** t1 and t2 are considered close enough if Math.abs(t1-t2) public static

 HERE IS THE CODE WE ARE GIVEN TO START WITH. public

HERE IS THE CODE WE ARE GIVEN TO START WITH.

public class MaxTemp{ /** t1 and t2 are considered close enough if Math.abs(t1-t2)  public static final double EPSILON = 0.01; /* add attributes as you need */ /* ---------------------------------------------------- * constructor * ---------------------------------------------------- */ public MaxTemp(Temperature[] temperatures){ // add your code here } /* ---------------------------------------------------- * getter * ---------------------------------------------------- */ public double[] getMax(){ // - returns an array of length 2 [max, count] // where max is the maximum temperature (expressed in the Kelvin scale) // of all Temperature objects passed to the constructor, and count // is the number of times that temperature was present (in the input // array of the constructor) // If there are no temperatures then return the array [0.0, 0.0] return new double[]{0.1, 0.2, 0.3, 0.4}; } /* OPTIONAL - use your main method to test your code */ public static void main(String[] args){ // testing code here is optional } } 

Complete the MaxTemp class. The class consists of a single constructor and a single getter method The constructor takes an array of Temperature objects as input. The input will always be a reference to an array (and never null) . The getter method returns an array of doubles with exactly two doubles in it. If the object was created with one more more Temperature objects in the constructor's input array then the output consists of the maximum temperature of all Temperature objects passed to the constructor and a count of how many times that maximum was present in the array passed too the constructor (in that order). If zero Temperature objects were passed to the constructor (in the array) then the getter returns [0.0, 0.0] Note: The max temperature returned must be displayed in the Kelvin scale Note: Different Temperature objects in the array passed to the constructor may have different temperature scales set for themselves Since the Temperature objects will store a floating point number for the temperature, you will use the provided EPSILON constant in the MaxTemp class and consider two temperatures as equal if their absolute difference is smaller than EPSILON. Therefore, if Math.abs (temp1 - temp2)

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