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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started