public static double[] arrayAvg(double[, ] a)
double[] tempArray = new double[a.GetLength(0)];
for (int i = 0; i < a.GetLength(0); i++)
for (int j = 0; j < a.GetLength(1); j++)
double avg = sum / (a.GetLength(1));
public static void Main()
Console.WriteLine("How many students are in your class?");
int s1 = int.Parse(Console.ReadLine());
string[] studentnames = new string[s1];
Console.WriteLine("What are the names of your students?");
for (int i = 0; i < s1; i++)
studentnames[i] = Console.ReadLine();
Array.Sort(studentnames);
Console.WriteLine("How many grades does each student have?");
int s2 = int.Parse(Console.ReadLine());
double[, ] grades = new double[s1, s2];
for (int i = 0; i < s1; i++)
Console.WriteLine("What are the grades for " + studentnames[i] + "?");
for (int j = 0; j < s2; j++)
grades[i, j] = double.Parse(Console.ReadLine());
Console.WriteLine("These are the grades of your students:");
double[] average = arrayAvg(grades);
for (int i = 0; i < s1; i++)
Console.WriteLine(studentnames[i] + ":");
for(int j = 0; j < s1; j++)
Console.Write(grades[i, j] + "| ");
Console.Write(" Final Average:" + average[i]);
Console.WriteLine("\n______________________________________________");
Console.WriteLine("The following students failed:");
for(int i = 0; i < average.Length; i++)
Console.WriteLine(studentnames[i]);
Console.WriteLine("\nThe following students passed:");
for(int i = 0; i < average.Length; i++)
Console.WriteLine(studentnames[i]);