Write a Java Program to Calculate Arithmetic Mean of N numbers

By | 07.02.2017

Java Program to Calculate Arithmetic Mean of N numbers


Java Program to calculate the arithmetic mean of some numbers in Java Programming, you have to ask to the user to enter number size then ask to enter the numbers of that size to perform the addition, then make a variable responsible for the average and place addition/size in average, then display the result on the output screen.

SOURCE CODE ::

 

import java.util.Scanner;

public class Arithmetic_Mean
{
    public static void main(String args[])
    {
        int n, i, sum=0, armean;
        int arr[] = new int[50];
        Scanner scan = new Scanner(System.in);
                
        System.out.print("How many Number you want to Enter ? ");
        n = scan.nextInt();
                
        System.out.print("Enter " +n+ " Numbers : ");
        for(i=0; i<n; i++)
        {
            arr[i] = scan.nextInt();
            sum = sum + arr[i];
        }
                
        armean = sum/n;
                
        System.out.print("Arithmetic Mean = " +armean);
    }
}

 

OUTPUT ::

 

How many Number you want to Enter ? 6
Enter 6 Numbers : 4
1
8
3
5
6
Arithmetic Mean = 4

 

4.5 2 votes
Article Rating
Category: Basic Programs Java Programming Tags:

About Tunde A

My name is Tunde Ajetomobi, a Tech Enthusiast and Growth Hacker. I enjoy creating helpful content that solves problem across different topics. Codezclub is my way of helping young aspiring programmers and students to hone their skills and find solutions on fundamental programming languages.

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments