Question: IIN JAVA PLZ Problem 8: ExperimentData Sample values from an experiment often need to be smoothed out. One simple approach is to replace each value
IIN JAVA PLZ
Problem 8: ExperimentData Sample values from an experiment often need to be smoothed out. One simple approach is to replace each value in an array with the average of the value and its two neighboring values (or one neighboring value if it is at either end of the array). Implement a class ExperimentData that holds a set of numerical data in an array and does the smoothing. You must use the original array and modify the elements in place; do not create a new array. Experiment Data must include the following public methods (you may also include any private methods/fields that you want): ExperimentData (double[] values) // Constructor that constructs this ExperimentData object with the given array of values. Assume the values array will have at least 2 elements. double[] getValues() // returns the values void smooth() // smooths the array by averaging values with its neighbors Examples: ExperimentData datal = new ExperimentData (new double[] {3.2, 4.5, 8.0, 9.34, 10.0, 0.75}); datal.getValues(); // returns (3.2, 4.5, 8.0, 9.34, 10.0, 0.75] datal.smooth(); datal.getValues(); // returns [3.85, 5.233333333333333, 7.28, 9.113333333333333, 6.696666666666666, 5.375] ExperimentData data2 = new ExperimentData (new double[] {3, 6.2}); data2.getValues(); // returns (3.0, 6.2] data2.smooth(); data2.getValues(); // returns [4.6, 4.6]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
