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()
Console.WriteLine("How many grades would you like to enter?");
int num = int.Parse(Console.ReadLine());
float[] grades = new float[num];
for (int i = 0; i < num; i++)
Console.WriteLine("Please enter value number " + (i + 1));
grades[i] = float.Parse(Console.ReadLine());
Console.Write("Your grades from smallest to largest are: ");
foreach (float grade in grades)
Console.Write(grade + " ");
Console.WriteLine("\n The average of your grades is: " + grades.Average());
Console.WriteLine("\n The median of your grades is: " + Median(grades));
if (grades.Average() < 65)
Console.WriteLine("\n You are currently not passing. You need an average of 65 or above to be passing.");
else if (grades.Average() >= 65)
Console.WriteLine("\n You are currently passing. Good job and keep up the great work!");
Console.WriteLine("\n Would you like to run the program again? Press q to quit or any other key to continue.");
restart = Console.ReadLine();