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 = {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());
for(int i = 0; i<ages.Length;i++)
{Console.Write(ages[i] + " ");}
float output = Median(ages);
Console.WriteLine("The Median of the numbers are " + output);