In this tutorial, we will see simple Java Program to Calculate Arithmetic mean.
Here is simple algorithm to calculate arithmetic mean.
- Calculate sum of elements in the array
- Divide it by total number of element in the array.
import java.util.Scanner; public class ArithMeanCalc { public static void main(String args[]) { int cnt, i, sum=0, mean; int numArr[] = new int[50]; Scanner scan = new Scanner(System.in); System.out.print("Please enter count of numbers you want to Enter ? "); cnt = scan.nextInt(); System.out.print("Enter " +cnt+ " Numbers : "); for(i=0; iPlease enter count of numbers you want to Enter ? 5
Enter 5 Numbers : 67 54 65 38 96
Arithmetic Mean = 64
The post Java program to calculate arithmetic mean appeared first on Java2Blog.