Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please show final output and display. Thank you. Objective: Arrays and Unit Tests. I. Write a class Stats that has methods used to compute various

image text in transcribed

Please show final output and display. Thank you.

Objective: Arrays and Unit Tests. I. Write a class Stats that has methods used to compute various statistics about the data passed in its constructor. Provide the following instance methods: 1. A constructor that takes an int array as its parameter, sets this parameter as an array in instance variable in the class, and then sorts this instance variable ascending order. You may use the sort method in the Arrays class to sort this data. 2. The method average that returns the average of all the elements in the instance 3. 4. 5. The method standardDeviation that returns the standard deviation of all the variable array The method max that returns the maximum value in the instance variable array The method min that returns the minimum value in the instance variable array elements in the instance variable array. Use the formula below The standard deviation of a collection of N numbers x,xxy is defined as where avg is the average of the numbers. Make sure you call the average method from within this method. 6. The method median that returns the median value (middle element in a sorted array of odd size, average of the two middle elements for sorted arrays of even size) in the instance variable array II. Then, create a StatsDriver class that creates a 20 element int array and populates it with random elements in the range 10 through 95 (both inclusive). This driver class should then test each of the instance methods in the class, printing the output. Use the java.util.Random class with a seed of 2625 to generate repeatable output for the data. III. Finally, create a StatsTest JUnit class. In this class, provide test methods for the min, and max methods only in the Stats class. You should select appropriate test cases in each method to ensure that the methods work exactly as expected. Objective: Arrays and Unit Tests. I. Write a class Stats that has methods used to compute various statistics about the data passed in its constructor. Provide the following instance methods: 1. A constructor that takes an int array as its parameter, sets this parameter as an array in instance variable in the class, and then sorts this instance variable ascending order. You may use the sort method in the Arrays class to sort this data. 2. The method average that returns the average of all the elements in the instance 3. 4. 5. The method standardDeviation that returns the standard deviation of all the variable array The method max that returns the maximum value in the instance variable array The method min that returns the minimum value in the instance variable array elements in the instance variable array. Use the formula below The standard deviation of a collection of N numbers x,xxy is defined as where avg is the average of the numbers. Make sure you call the average method from within this method. 6. The method median that returns the median value (middle element in a sorted array of odd size, average of the two middle elements for sorted arrays of even size) in the instance variable array II. Then, create a StatsDriver class that creates a 20 element int array and populates it with random elements in the range 10 through 95 (both inclusive). This driver class should then test each of the instance methods in the class, printing the output. Use the java.util.Random class with a seed of 2625 to generate repeatable output for the data. III. Finally, create a StatsTest JUnit class. In this class, provide test methods for the min, and max methods only in the Stats class. You should select appropriate test cases in each method to ensure that the methods work exactly as expected

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Structure Of The Relational Database Model

Authors: Jan Paredaens ,Paul De Bra ,Marc Gyssens ,Dirk Van Gucht

1st Edition

3642699588, 978-3642699580

More Books

Students also viewed these Databases questions