Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using netbeans write a code for java: (Statistics: compute mean and deviation) P

ID: 3769463 • Letter: U

Question

Using netbeans write a code for java:

(Statistics: compute mean and deviation) Programming Exercise 5.37 computes the standard deviation of numbers. This exercise uses a different but equivalent formula to compute the standard deviation of N numbers:


To compute the standard deviation with this formula, you have to store the individual numbers using an array, so they can be used after the mean is obtained.
Your program should contain the following methods:

public static double deviation(double[] x)

public static double mean(double[] x)

Write a test program that prompts the user to enter ten numbers and displays the mean and standard 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
Th standard deviation is 1.55738

Explanation / Answer

code: I have inplemented using standard formula for standard deviation because your images were not displayed. if you provide the link for those images in the comment I change the formula.

Thank you.

import java.io.* ;
import java.util.*;
import java.lang.*;

class abc {
public static void main(String args[])
{
Scanner inp = new Scanner(System.in);
System.out.print("Enter ten numbers: ");
double[] x=new double[10];
double n;
for(int i=0;i<10;i++){
n=inp.nextDouble();
x[i]=n;
}
System.out.print("The mean is ");
System.out.println(mean(x));
System.out.print("The standard deviation is ");
System.out.println(deviation(x));
  
  
              
}
public static double deviation(double[] x){
double m=mean(x);
double sd=0.0;
for(int i=0;i<10;i++){
sd=sd+((x[i]-m)*(x[i]-m));
}
sd=sd/10.0;
sd=Math.sqrt(sd);
return sd;

}

public static double mean(double[] x){
double m=0.0;
for(int i=0;i<10;i++){
m=m+x[i];
}
return m/10.0;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote