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 = {20, 16, 14, 16, 17, 15, 15, 15, 15, 16, 16, 17, 14, 16, 17, 15, 15, 15, 17, 17, 52};
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 ages of the people in Ms. Segal's 4th period class are: ");
for (int i = 0; i < other.Length; i++)
Console.Write(other[i] + " ");
float [] agesCopy = new float[ages.Length];
Array.Copy(ages,agesCopy, ages.Length);
{Console.Write(agesCopy[i] + " ");}
Console.WriteLine("The median of the ages in this class is: " + Median(ages));