Question: Activity - In java implement a program uses an ArrayList of any API numeric object type that extends the API Number class(such as Integer, Double,

Activity - In java implement a program uses an ArrayList of any API numeric object type that extends the API Number class(such as Integer, Double, Long) and calculates the average and standard deviation of its elements.

A)Create a Class called MyMathClass

1.The class handles bound type parameters that extend the API Number class. See Bound for Type Parameters(around pg 793 in text)

2.average method

a.takes in a type parameter ArrayList

b.returns a double representing the average of the ArrayList elements

3.standardDeviation method

a.that takes in a type parameter ArrayList

b.returns a double representing the Standard Deviation of the ArrayList elements.

c.Standard Deviation Equation

1.Sqrt of the sum of the difference between each element in the array and the average of all elements in the array.

2.Standard Deviation = Sqrt( (Sum_i=1_to_N(element i - average)) / N) where N is the number of elements in the array.

B)Create a Class classed MyMathClassTester

1.Creates three ArrayLists, one for each type of numeric Object Type(Integer, Double and Long)(you must use an L fpr any number literal to a Long before passing it to the List)(example 2348575758390L)

2.Add at least three appropriate number to each ArrayList

3.Create a MyMathClass object for each type (Integer, Double and Long)

4.Call the Standard Deviation method for each MyMathClass object and display the results.

5. What happens if you create a MyMathClass object with a String type parameter?

6.Add the answer to the above question as comments at the bottom of your MyMathClassTester

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!