static private float Median(float[] array)
float[] tempArray = array;
int count = tempArray.Length;
float middleElement1 = tempArray[(count / 2) - 1];
float middleElement2 = tempArray[(count / 2)];
medianValue = (middleElement1 + middleElement2) / 2;
medianValue = tempArray[(count / 2)];
public static void Main()
float[] ages = {37, 16, 17, 14, 17, 15, 18, 14, 14, 17, 14, 15, 16, 14, 16, 15, 17, 15, 16, 16, 14, 17, 15};
Console.WriteLine("The ages of the people in Ms. Durning's 9th period class are: ");
for (int i = 0; i < ages.Length; i++)
Console.Write(ages[i] + " ");
Console.WriteLine("\n The average of the ages in the class is " + ages.Average());
float[] agesCopy = new float[ages.Length];
Array.Copy(ages, agesCopy, ages.Length);
Console.WriteLine("The number of people in the class is: " + ages.Length);
Console.WriteLine("The ages in order are: ");
for (int i = 0; i < ages.Length; i++)
Console.Write(agesCopy[i] + " ");
Console.WriteLine("\n The median of this set of numbers is: " + Median(ages));