Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

home / study / questions and answers / engineering / computer science / define a

ID: 3671224 • Letter: H

Question

home / study / questions and answers / engineering / computer science / define a class quiz that implements the measurable ...

Your question has been answered! Rate it below.

Let us know if you got a helpful answer.

Question

Define a class Quiz that implements the Measurable interface. A quiz has a score and a letter grade (such as B+). Use the DataSet class that I have provided to process a collection of quizzes. Do not edit the DataSet class provided. Display the average score and the quiz with the highest score(both letter and score). Import a Scanner.

/**
* Computes the average of a set of data values.
*/

public class DataSet
{
private double sum;
private Object maximum;
private int count;
private Measurer measurer;

/**
*Constructs an empty data set.
*/

public DataSet(Measurer aMeasurer)
{

sum = 0;
count = 0;
maximum = null;
measurer = aMeasurer;
}

/**
Adds a data value to the data set.
*/

public void add(Object x)
{
sum = sum + measurer.measure(x);
if (count == 0 || measurer.measure(maximum) < measurer.measure(x))
maximum = x;
count++;
}

/**
Gets the average of the added data
*/
  
public double getAverage()
{
if (count == 0) return 0;
else return sum / count;

}

/**
Gets the largest of the added data
*/

public Object getMaximum()
{
return maximum;
}
}

Explanation / Answer

__________

_________________

_________________