Ok, the program is supposed to take a .DATA file of names and quiz grades, and then display all the grades and the averaged grade score. Now, I have most of it working, all I need to do is use a single dimensional array to read the list and calculate all the information, but not just one piece at a time(what I have now). In the end it will be nicely organized with each students name, grade, and 6 quiz grades displayed.
I know this looks confusing, I have my sorry attempt at an array commented out. I think I tried mixing a single dimensional array with a multi dimensional, and I got confused. My assignment is almost two weeks late, and the C# tutor doesn't know arrays. Any help would be great, my finals are soon, and I have to get this done ASAP. Thank you.
using System;
using System.Collections.Generic;
using System.Text;
namespace QuizStatistics
{
public class ClassStatistics
{
private string firstName;
private string lastName;
private double[] quizGrades;
public ClassStatistics()
{
}
public ClassStatistics(string firstName, string lastName, double[] scores)
{
this.firstName = firstName;
this.lastName = lastName;
this.quizGrades = scores;
}
public void DisplayObjectState()
{
//for (int kk = 0; kk < studentCount; ++kk)
//{
// Console.WriteLine("{0,7}{1,6}{2,6}{3,6}{4,6}{5,6}{6,6}{7,6}{8,6}{9,6}"
// , FirstName[kk]
// , LastName[kk]
// , avgGradeRounded(kk)
// , quizGrades[kk, 0]
// , quizGrades[kk, 1]
// , quizGrades[kk, 2]
// , quizGrades[kk, 3]
// , quizGrades[kk, 4]
// , quizGrades[kk, 5]
// );
//}
}
public double lowestGrade()
{
double lowest = quizGrades[0];
foreach (double dbl in quizGrades)
{
if (dbl < lowest)
{
lowest = dbl;
}
}
return lowest;
}
public int gradeAverageRoundUp()
{
double average = (sumOfGrades() - lowestGrade()) / (quizGrades.Length - 1);
int averageRoundDown = (int)average;
if (average == (double)averageRoundDown)
{
return averageRoundDown;
}
else
{
return averageRoundDown + 1;
}
}
public char LetterGrade()
{
int Total = (int)gradeAverageRoundUp();
if ((Total) >= 90)
{
return 'A';
}
if ((Total >= 80) && (Total <= 89))
{
return 'B';
}
if ((Total >= 70) && (Total <= 79))
{
return 'C';
}
if ((Total >= 60) && ((Total) >= 69))
{
return 'D';
}
if (Total <= 59)
{
return 'F';
}
else
return '0';
}
public double sumOfGrades()
{
double accumulator = 0;
for (int row = 0; row < quizGrades.Length; ++row)
{
accumulator += quizGrades[row];
}
return accumulator;
}
//public double[] ClassQuizAvgArray()
//{
// double[] AvgArray = new double[quizGrades.GetLength(1)];
// for (int col = 0; col < quizGrades.GetLength(1); ++col)
// {
// AvgArray[col] = (double)sumOfGrades(col) / studentCount;
// }
// return AvgArray;
//}
//public void DisplayLine()
//{
// for (int kk = 0; kk < studentCount; ++kk)
// {
// Console.WriteLine("{0,8:f0}{1,8:f0} {2,6:f0}{3,6:f0}{4,6:f0}{5,6:f0}{6,6:f0}{6,7:f0}"
// , lastName
// , firstName
// , avgGradeRounded(kk)
// , quizGrades[0]
// , quizGrades[1]
// , quizGrades[2]
// , quizGrades[3]
// , quizGrades[4]
// , quizGrades[5]
// );
// }
// Console.WriteLine("\n");
// double[] classDouble = avgGradeRounded();
// Console.WriteLine
// ("Average \n{0,6:f1}\n{1,6:f1}\n{2,6:f1}\n{3,6:f1}\n{4,6:f1}"
// , classDouble[0]
// , classDouble[1]
// , classDouble[2]
// , classDouble[3]
// , classDouble[4]);
}
}