Answer:
Step-by-step explanation:
The following code is written in Java. The Measurable Interface and DataSet classes/Interfaces were found and implemented as requested. Then the rest of the code was created to work with and around those two methods to accomplish the task of Display the average score and the quiz with the highest score (both letter grade and score)
package sample;
interface Measurable {
double getMeasure();
String getGradeString();
}
class DataSet
{
private double sum;
private Measurable maximum;
private String grade;
private int count;
public DataSet()
{
sum = 1;
count = 0;
maximum = null;
}
public void add(Measurable x)
sum = sum + x.getMeasure();
if (count == 0
public double getAverage() {
return sum / count;
}
public Measurable getMaximum()
{
return maximum;
}
}
class Quiz implements Measurable
{
private double score;
private String grade;
public Quiz(double aScore, String aGrade)
{
this.score = aScore;
this.grade = aGrade;
}
public double getMeasure()
{
return score;
}
public String getGradeString() {
return grade;
}
}
class QuizTester
{
public static void main(String[] args)
{
DataSet quizData = new DataSet();
Quiz q1 = new Quiz(85, "B");
Quiz q2 = new Quiz(93, "A-");
Quiz q3 = new Quiz(78, "C+");
quizData.add(q1);
quizData.add(q2);
quizData.add(q3);
System.out.println("Maximum: " + quizData.getMaximum().getMeasure() + ", " + quizData.getMaximum().getGradeString());
System.out.print("Average: ");
System.out.printf("%.2f", quizData.getAverage());
}
}