Question
E9.17 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
E9.17 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.
E9.18 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.
E9.19 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.
E9.20 Add static methods largest and smallest to the Measurable interface. The methods should return the object with the largest or smallest measure from an array of Measurable objects.
E9.21 In the Sequence interface of Worked Example 9.2, add static methods that yield Sequence instances:
static Sequence multiplesOf(int n) static Sequence powersOf(int n)
For example, Sequence.powersOf(2) should return the same sequence as the SquareSequence class in the worked example. E9.22 In Worked Example 9.2, add a default method
default int[] values(int n)
that yields an array of the first n values of the sequence.
E9.23 In Worked Example 9.2, make the process method a default method of the Sequence interface.
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