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

***Please make sure the code runs in Netbeans Java SE*** Statistics: compute mea

ID: 3827274 • Letter: #

Question

***Please make sure the code runs in Netbeans Java SE***

Statistics: compute mean and standard deviation.

Write a program that prompts the user to enter ten numbers, and displays the mean and standard deviations of these numbers using the following formula:

5.45 Statistics: compute mean and standard deviation) In business applications, you are often asked to compute the mean and standard deviation of data. The mean is simply the average of the numbers. The standard deviation is a statistic that tells 200 Chapter 5 Loops you how tightly all the various data are clustered around the mean in a set of data. For example, what is the average age of the students in a class? How close are the ages? If all the students are the same age, the deviation is 0. Write a program that prompts the user to enter ten numbers, and displays the mean and standard deviations of these numbers using the following formula: X deviation mean Here is a sample run: Enter ten numbers: 1 2 3 4.5 5.6 6 7 8 9 10 -Enter The mean is 5.61 The standard deviation is 2.99794

Explanation / Answer

import java.util.Scanner;

public class MDCalculater {
  
   public static void main(String[] args) {
       double n = 0.0d;
       double sigmaX = 0.0d;
       double sigmaX2 = 0.0d;
       double mean = 0.0d;
       double standardDeviation = 0.0d;
      
       Scanner scanner = new Scanner(System.in);
       System.out.println("Enter ten numbers:");
       String input = scanner.nextLine();
       String data[] = input.split(" ");
       for(int i = 0;i<data.length;i++){
           double value = Double.parseDouble(data[i]);
           sigmaX += value;
           sigmaX2 += (value*value);
       }
       n = data.length;
       //System.out.println("N:"+n);
       //System.out.println("sigmaX:"+sigmaX);
       //System.out.println("sigmaX2:"+sigmaX2);
       mean = sigmaX/n;
       standardDeviation = Math.sqrt( (sigmaX2-((sigmaX*sigmaX)/n)) /(n-1.0d));
       System.out.println("The mean is : "+mean);
       System.out.println("The standard deviation is: "+standardDeviation);       
   }

}