public static void Main()
float[] ages = {17, 40, 15, 14, 15, 14, 15, 14, 15, 14, 15, 14, 16, 14, 15, 14, 17, 14, 17, 14, 17, 15, 14, 14, 17, 14};
Console.WriteLine("The ages of the people in Ms. Segal's 4th period class are: ");
for (int i = 0; i < ages.Length; i++)
Console.Write(ages[i] + " ");
Console.WriteLine("There are " + ages.Length + " people in the class.");
Console.WriteLine("The average of the ages in the class is " + ages.Average());
float[] other = new float[ages.Length];
Array.Copy(ages, other, ages.Length);
Console.WriteLine("The ages from least to greatest are: ");
for (int i = 0; i < ages.Length; i++)
Console.Write(ages[i] + " ");
Console.WriteLine("The median of the numbers is: " + Median(ages).ToString("##.##"));
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)];