The intended result is that output1 contains 10 90 250


Question: Method transform takes two identically sized-arrays as parameters: input and output, and a third parameter representing a function to be applied to the input array.

For instance, in the following code fragment:

double [] input = { 1.0, -3.0, 5.0 };

double [] output1 = new double [3];

double [] output2 = new double [3];

double [] output3 = new double [4];

transform(input, output1, new ComputerSquare() );

transform(input, output2, new ComputerAbsoluteValue() );

transform(input, output3, new ComputerSquare() );

The intended result is that output1 contains 1.0, 9.0, 25.0, output2 contains 1.0, 3.0, 5.0, and the third call to transform throws an IllegalArgumentException because the arrays have different sizes. Implement the following components:

a. An interface that will be used to specify the third parameter to transform.

b. The transform method (which is a static method). Remember to throw an exception if the input and output arrays are not identicallysized.

c. The classes ComputeSquare and ComputeAbsoluteValue

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: The intended result is that output1 contains 10 90 250
Reference No:- TGS02457431

Now Priced at $15 (50% Discount)

Recommended (99%)

Rated (4.3/5)