my assignment is to retrieve data from a txt file and output how many tests were input, average of all the tests, and then list the letter grade beside each text
what i have so far:
private StreamReader strRead;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
int[] gradeArray = new int[24]; // array to hold grades
string gradeValue = ""; // string to hold current grade;
strRead = new StreamReader("Grades.txt"); // streamreader for input file
int traverseGradeArray = 0; // index used for gradeArray.
int averageGrades = 0;
int totalGrades = 0;
int numberofGrades = 0;
// initialize gradeArray elements to -1
for (int i = 0; i < 24; i++)
{
gradeArray[i] = -1;
} // for int i
// while not at the end of the file
while ((gradeValue = fil.ReadLine()) != null)
{
// set current gradeArray value to what was read from file.
gradeArray[traverseGradeArray] = Convert.ToInt32(gradeValue);
// increment element counter
traverseGradeArray++;
} // while not at the end of the file
// output contents of gradeArray to listBox
for (int i = 0; i < 24; i++)
totalGrades = totalGrades + gradeArray[i];
averageGrades = totalGrades / 24;
listBoxOutput.Items.Add(averageGrades);
gradeArray = new int[24];
totalGrades = gradeArray.Length;
listBoxOutput.Items.Add(totalGrades);
for (int i = 0; i < 24; i++)
if (gradeArray[i] >= 91)
{
this.listBoxOutput.Text = "A";
}
}
stuck & stressed..PLEASE HELP!