**Objective:**

The BlueJ Program finds the mean and median values from the Array of values inputted by the User by simple formula on Statistics. The mean is the sum of the values divided by the number of values. The mean of a set of numbers

*x*

_{1},

*x*

_{2}, ...,

*x*

_{n}is typically denoted by , pronounced "

*x*bar". This mean is a type of arithmetic mean. If the data set were based on a series of observations obtained by sampling a statistical population, this mean is termed the "sample mean" () to distinguish it from the "population mean" (μ or μ

_{x}). The mean is often quoted along with the standard deviation: the mean describes the central location of the data, and the standard deviation describes the spread. An alternative measure of dispersion is the mean deviation, equivalent to the average absolute deviation from the mean. It is less sensitive to outliers, but less mathematically tractable.

The

*arithmetic mean*is the "standard" average, often simply called the "mean".

The mean may often be confused with the median, mode or range. The mean is the arithmetic average of a set of values, or distribution; however, for skewed distributions, the mean is not necessarily the same as the middle value (median), or the most likely (mode). For example, mean income is skewed upwards by a small number of people with very large incomes, so that the majority have an income lower than the mean. By contrast, the median income is the level at which half the population is below and half is above. The mode income is the most likely income, and favors the larger number of people with lower incomes. The median or mode are often more intuitive measures of such data.

Nevertheless, many skewed distributions are best described by their mean – such as the exponential and Poisson distributions.

For example, the arithmetic mean of six values: 5, 10, 13, 7, 25, 31 is

### Geometric mean (GM)

The geometric mean is an average that is useful for sets of positive numbers that are interpreted according to their product and not their sum (as is the case with the arithmetic mean) e.g. rates of growth.

For example, the geometric mean of six values: 34, 27, 45, 55, 22, 34 is:

### Harmonic mean (HM)

The harmonic mean is an average which is useful for sets of numbers which are defined in relation to some unit, for example speed (distance per unit of time).

For example, the harmonic mean of the six values: 34, 27, 45, 55, 22, and 34 is

M

**edian**is described as the numerical value separating the higher half of a sample, a population, or a probability distribution, from the lower half. The

*median*of a finite list of numbers can be found by arranging all the observations from lowest value to highest value and picking the middle one.

**Screenshot:**

**Program Source Code:**

/** * The Program calculates the Mean and Median of the data provided by the user. * © SHANTANU KHAN * @ shantanukhan1995@gmail.com * @website 0code.blogspot.com * Program Type : BlueJ Program - Java */ import java.io.*; import java.util.*; public class Mean_Median { private int[]arr; private int size; static Scanner sc= new Scanner(System.in); //Declaration of Scanner Class public Mean_Median(int n) // Constructor { arr=new int[size=n]; } public void Input() //Taking input { for(int i=0;i<size;i++) { System.out.print("Enter the Integer No. "+(i+1)+" : "); arr[i]= sc.nextInt(); } } public void bubbleSort() //Sorting the Data Provided { for(int i=1;i<size;i++) { for(int j=0;j<size-i;j++) { if(arr[j]>arr[j+1]) { int temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } } } } public double Mean() //Calculate the Mean { double sum=0; for(int i=0;i<size;i++) { sum+=arr[i]; } return sum/size; } public double Median() //Calculate the Median { int mid = size/2; if(size%2!=0) return((double)(arr[mid])); else return(arr[mid-1]+arr[mid])/2.0; } public static void main(String []args) // Main Method { System.out.print(" Enter size of array : "); int n =sc.nextInt(); Mean_Median obj = new Mean_Median(n) ; // Object Creation obj.Input(); System.out.println("Mean = "+obj.Mean()); obj.bubbleSort(); System.out.println("Median = "+obj.Median()); } }