Java double type calculate mean

Description

Java double type calculate mean


import java.util.Scanner;

public class Main {

    public static void main(String[] strings) {

        double total = 0.0;

        Scanner input = new Scanner(System.in);
        System.out.print("Enter a number: ");

        for (int i = 0; i < 10; i++) {
            double number = input.nextDouble();
            total += number;/*from  w  w w .  ja  va 2s. c om*/
        }
        double mean = total / 10.0;

        System.out.println("The mean is " + mean);

    }
}



PreviousNext

Related