Karanbir S.

asked • 05/03/21

help me output either a list of failing students (Less than 65) or a list of students on honor roll(above 90). ONLY USING A LOOP AND IF STATEMEN

using System;


public class Program

{

public static double[] arrayAvg(double[, ] a)

{

double[] tempArray = new double[a.GetLength(0)];

double sum = 0;

for (int i = 0; i < a.GetLength(0); i++)

{

for (int j = 0; j < a.GetLength(1); j++)

{

sum = sum + a[i, j];

}


double avg = sum / (a.GetLength(1));

tempArray[i] = avg;

sum = 0;

}


return tempArray;

}


public static void Main()

{

Console.WriteLine("How many students do you have?");

int students = int.Parse(Console.ReadLine());

string[] names = new string[students];

Console.WriteLine("Type your students names, pressing enter after each one");

for (int i = 0; i < names.Length; i++)

{

names[i] = Console.ReadLine();

Console.Clear();

}


Array.Sort(names);

Console.WriteLine("How many grades for each student?");

int numofgrades = int.Parse(Console.ReadLine());

double[, ] grades = new double[students, numofgrades];

for (int i = 0; i < grades.GetLength(0); i++)

{

Console.WriteLine("Please enter the grades for " + names[i]);

for (int j = 0; j < grades.GetLength(1); j++)

grades[i, j] = double.Parse(Console.ReadLine());

}


double[] myavg = arrayAvg(grades);

Console.WriteLine("Here's your gradebook!");

for (int i = 0; i < students; i++)

{

Console.Write(names[i] + ": ");

for (int j = 0; j < numofgrades; j++)

Console.Write(grades[i, j] + " ");

Console.Write("Final Average: " + myavg[i]);

Console.WriteLine();

}

}

}


using System;


public class Program

{

public static double[] arrayAvg(double[, ] a)

{

double[] tempArray = new double[a.GetLength(0)];

double sum = 0;

for (int i = 0; i < a.GetLength(0); i++)

{

for (int j = 0; j < a.GetLength(1); j++)

{

sum = sum + a[i, j];

}


double avg = sum / (a.GetLength(1));

tempArray[i] = avg;

sum = 0;

}


return tempArray;

}


public static void Main()

{

Console.WriteLine("How many students do you have?");

int students = int.Parse(Console.ReadLine());

string[] names = new string[students];

Console.WriteLine("Type your students names, pressing enter after each one");

for (int i = 0; i < names.Length; i++)

{

names[i] = Console.ReadLine();

Console.Clear();

}


Array.Sort(names);

Console.WriteLine("How many grades for each student?");

int numofgrades = int.Parse(Console.ReadLine());

double[, ] grades = new double[students, numofgrades];

for (int i = 0; i < grades.GetLength(0); i++)

{

Console.WriteLine("Please enter the grades for " + names[i]);

for (int j = 0; j < grades.GetLength(1); j++)

grades[i, j] = double.Parse(Console.ReadLine());

}


double[] myavg = arrayAvg(grades);

Console.WriteLine("Here's your gradebook!");

for (int i = 0; i < students; i++)

{

Console.Write(names[i] + ": ");

for (int j = 0; j < numofgrades; j++)

Console.Write(grades[i, j] + " ");

Console.Write("Final Average: " + myavg[i]);

Console.WriteLine();

}

}

}

1 Expert Answer

By:

Patrick B. answered • 05/05/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Karanbir S.

I Got short and sweet. using System; public class Program { public static double[] arrayAvg(double[, ] a) { double[] tempArray = new double[a.GetLength(0)]; double sum = 0; for (int i = 0; i < a.GetLength(0); i++) { for (int j = 0; j < a.GetLength(1); j++) { sum = sum + a[i, j]; } double avg = sum / (a.GetLength(1)); tempArray[i] = avg; sum = 0; } return tempArray; } public static void Main() { Console.WriteLine("How many students do you have?"); int students = int.Parse(Console.ReadLine()); string[] names = new string[students]; Console.WriteLine("Type your students names, pressing enter after each one"); for (int i = 0; i < names.Length; i++) { names[i] = Console.ReadLine(); Console.Clear(); } Array.Sort(names); Console.WriteLine("How many grades for each student?"); int numofgrades = int.Parse(Console.ReadLine()); double[, ] grades = new double[students, numofgrades]; for (int i = 0; i < grades.GetLength(0); i++) { Console.WriteLine("Please enter the grades for " + names[i]); for (int j = 0; j < grades.GetLength(1); j++) grades[i, j] = double.Parse(Console.ReadLine()); } double[] myavg = arrayAvg(grades); Console.WriteLine("Here's your gradebook!"); for (int i = 0; i < students; i++) { Console.Write(names[i] + ": "); for (int j = 0; j < numofgrades; j++) Console.Write(grades[i, j] + " "); Console.Write("Final Average: " + myavg[i]); Console.WriteLine(); } Console.WriteLine("The following students failed: "); for(int i = 0; i
Report

05/07/21

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.