-1

A program that prompts the user to enter ten numbers and displays their mean and standard deviation. The mean and standard deviation of n numbers are computed as follows:

enter image description here

The code that solve the equation

 import java.util.Scanner;
 public class Exercises5 {
 public static void main(String[] args) {
  Scanner input = new Scanner(System.in);
  double [] numbers = new double [10] ; 
  System.out.print("Enter ten numbers: ");
    for (int i = 0; i < 10; i++) 
        numbers[i] = input.nextDouble();
            
    double mean,deviation;
           
            mean = mean(numbers);
            deviation = std(numbers, mean);
            
            System.out.println("The mean is " + mean);
        System.out.printf("The standard deviation is %.5f\n", deviation);
            
  }
  public static double mean(double numArray[]){
        double sum = 0.0;
        int length = numArray.length;
        for(double num : numArray)
        sum += num;
    
        double mean = sum/length;
        
        return mean;
    }
 
    public static double std(double numArray[] , double mean{
    double standardDeviation = 0.0;
    int length = numArray.length;
    for(double num: numArray) {
        standardDeviation += Math.pow(num - mean, 2);
    }
   return Math.sqrt(standardDeviation /(length - 1));
  }
}
Community
  • 1
  • 1
Basma Elshoky
  • 151
  • 1
  • 10

1 Answers1

1

The only issue that I can see is on line 30:

public static double std(double numArray[] , double mean{

It is missing the closing parenthesis after double mean:

public static double std(double numArray[], double mean) {

Osmund Francis
  • 771
  • 10
  • 27