This exercise uses a different but equivalent formula to compute the standard de
ID: 3642823 • Letter: T
Question
This exercise uses a different but equivalent formula to compute the standard deviation of n numbers. (You must compute the mean of the n numbers first. The mean is simply the average of the n numbers.)mean = (x1 + x2 + x3 + ... + xn)/n //n is the number of numbers
deviation = sqrt(((x1 - mean)2 + (x2 - mean)2 + ... + (xn - mean)2)/(n - 1))
To compute deviation with this formula, you have to store the individual numbers using an array, so that they can be used after the mean is obtained.
Your program should contain the following methods:
//Compute the mean of an array of double values
public static double mean(double[ ] x)
//Compute the deviation of the double values
public static double deviation(double[ ] x)
Write a test program that declares and creates an array of double values. Then prompts the user to enter ten (10) numbers from the keyboard and displays the mean and deviation, as shown in the following sample run.
Enter ten numbers: 1.9 2.5 3.7 2 1 6 3 4 5 2
The mean is 3.11
The standard deviation is 1.55738
Explanation / Answer
import java.util.*; public class Random { public static double mean(double[] x) { double ans = 0; for(int i=0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.