简体   繁体   中英

Statistical Analysis

I am working on a statistical analysis program that will calculate a number of things. I don't need help on the build, because I understand how that needs to be completed. The issue that I am having deals with the array I built. I get a really weird output when i try to display the data. Below is the output

public class Project_StatisticalAnalysis {

    public static void main(String[] args){


        System.out.println("Good Day,");
        System.out.println();
        System.out.println("This program can run statistical analysis on integer");
        System.out.println("data up to 100 values; it can calculate the mean,");
        System.out.println("median, mode, variance and standard deviation.");
        System.out.println("");

        Scanner input = new Scanner(System.in);
        System.out.println("Please enter the number of values you will be calculating: ");
        int values = input.nextInt();

        //Create Array
        final int numArray = values;
        double [] numberValues = new double[numArray];
        double sum = 0; 
        for (int i = 0; i < numArray; i++){
            System.out.println("Please enter a number:");
        numberValues[i] = input.nextDouble();
        sum += numberValues[i];
        }
        //Call to Methods:
        displayNumbers(numberValues, values);
        sort(numberValues);
        mean(numberValues);
        median(numberValues);
        mode(numberValues);
        standardDeviation(numberValues);
        variance(numberValues);     
        }

        public static void displayNumbers(double numberValues[], double values) {
            System.out.println("You entered:");
            System.out.println();
            int count = 0;
            for (int i = 0; i <values; i++){
            System.out.print(numberValues+" ");         
            count++;
            if (count == 10) {
                System.out.println();
                count = 0;
            }}


        }

        public static void sort(double numberValues[]){

        }

        public static void mean(double numberValues[]){


        }

        public static void median(double numberValues[]){

        }

        public static void mode(double numberValues[]){

        }

        public static void standardDeviation(double numberValues[]){

        }

        public static void variance(double numberValues[]){


        }
}

The output is:

Good Day,

This program can run statistical analysis on integer
data up to 100 values; it can calculate the mean,
median, mode, variance and standard deviation.

Please enter the number of values you will be calculating: 
12
Please enter a number:
4
Please enter a number:
4
Please enter a number:
4
Please enter a number:
4
Please enter a number:
4
Please enter a number:
4
Please enter a number:
5
Please enter a number:
8
Please enter a number:
4
Please enter a number:
5
Please enter a number:
4
Please enter a number:
4
You entered:

[D@5c647e05 [D@5c647e05 [D@5c647e05 [D@5c647e05 [D@5c647e05 [D@5c647e05 [D@5c647e05 [D@5c647e05 [D@5c647e05 [D@5c647e05 
[D@5c647e05 [D@5c647e05 

Instead

System.out.print(numberValues+" "); //displays address

write

System.out.print(numberValues[i]+" "); //displays value here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM