Let's compute a few summary statistics on a dataset.
Create a method named summarizeValues
that accepts an array of double
values.
The array will not be null
and will not be empty.
Compute the mean and the range of the dataset and return a String
in the following format:
Mean: <mean>
Range: <range>
Where <mean>
and <range>
are the mean and range of the dataset computed by your method.
Round the values to 2 decimal points using a method round
which accepts a double
value.
For example, round(3.33542)
would return 3.34
.
Given the array {1.0, 2.0, 4.0}
, your method should return:
Mean: 2.33
Range: 3.0
You're challenge is to write tests for this problem described above.
Stuck? You may find these lessons helpful: