Question: Given the two java source files: Data.java and Measurable.java. Finish the following problems based on these files. Implement a class Country that implements the Measurable
Given the two java source files: Data.java and Measurable.java. Finish the following problems based on these files. Implement a class Country that implements the Measurable interface. The class should have two instance variables: countrys name and total area of the country.
Add a method public static Measurable max(Measurable[] objects) to the Data class that returns the object with the largest measure.
Implement MeasurableTester class to create three Country objects and print out the maximum area among the three countries.
Implement a class Quiz that implements the Measurable interface. A quiz has a score and a letter grade (such as B+).
Implement QuizTester class to use the Data class to process an array of quizzes. Display the average score and the quiz with the highest score (both letter grade and score).
public class Data { /** Computes the average of the measures of the given objects. @param objects an array of Measurable objects @return the average of the measures */ public static double average(Measurable[] objects) { double sum = 0; for (Measurable obj : objects) { sum = sum + obj.getMeasure(); } if (objects.length > 0) { return sum / objects.length; } else { return 0; } } }
/** Describes any class whose objects can be measured. */ public interface Measurable { /** Computes the measure of the object. @return the measure */ double getMeasure(); } Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
