Modify the SodaCan class of Exercise P8.5 to implement the Measurable interface.
ID: 3554216 • Letter: M
Question
Modify the SodaCan class of Exercise P8.5 to implement the Measurable interface. The measure of a soda can should be its surface area. Write a program that computes the average surface area of an array of soda cans.
A person has a name and a height in centimeters. Use the average method in Section 9.6 to process a collection of Person objects.
Write a method
public static Measurable maximum(Measurable[] objects)
that returns the object with the largest measure. Use that method to determine the country with the largest area from an array of countries.
Declare an interface Filter as follows: public interface Filter
{
boolean accept(Object x);
}
Write a method
public static ArrayList<Object> collectAll(ArrayList<Object> objects, Filter f) that returns all objects in the objects array that are accepted by the given filter. Provide a class ShortWordFilter whose filter method accepts all strings of length < 5.
Then write a program that reads all words from System.in, puts them into an Array
Explanation / Answer
( Done EXACTLY following the mentioned Specifications )
Find the solution here : http://ideone.com/QFKIuu
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.