PROFESSIONAL ACADEMIC STUDY RESOURCES WEBSITE +1 813 434 1028  proexpertwritings@hotmail.com

Programming Question

Description

Program Assignment #3

OCA Chapters 5 and 6

The following should all be put into 1 Eclipse program. Zip and upload the project folder that you create to the Program Assignment #3 folder on D2L.

Define an interface named SomeFunction that has a method named evaluate that takes a double parameter and returns a double value.

Create a class named HalfIt that implements the SomeFunction interface. The implementation of the method evaluate() should return the value obtained by dividing the double parameter by 2.

In a “client” (i.e. a separate class), create a method that is invoked from your Main method that takes an arbitrary number of double values as a varargs parameter and returns an array that has a length equal to the number of values passed in the varargs parameter, but with each value of an element in the new array being half of the corresponding value in the varargs parameter. Have the implementation of this method create an instance of the HalfIt class, and, using the evaluate() method, to set the appropriate values in the returned array. This method should throw an appropriate exception if any of the vararg values are negative or if no values are passed to this method. This exception should properly be handled in the invoking method (probably your Main method). Also, in the invoking method, if all is well, display the contents of the array.

In your code, rather than deleting any code that you used to check out the requirements, just comment out the code. I want to be able to verify how you went about checking if your program “was doing what it was supposed to do”.

Share your love

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Your email address will not be published. Required fields are marked *