Q:

Write a Java Program to Calculate Arithmetic Mean of N numbers

belongs to collection: Java Basic Solved Programs

0

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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Java Basic Solved Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a Java program to convert Fahrenheit to Cels... >>
<< Write a Java Program to Perform Mathematical Opera...