المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : printing students grades after finding them in files..



C# Programming
04-24-2013, 01:31 AM
Im trying to create a program where there are two files for two separate classes.. after the user enters the course they want to show the grades and students name of the program searches through that file and gets all the students averages for each category then prints the final grade at the end. Right now I'm getting an error for "unexpected symbol public"on line 17 and "unexpected symbol }" at line 101


using System;
using System.IO;

namespace IntroCS
{
class GradeFiles
{

public static void Main(string[] args)
{






public static int codeIndex(string code, string[] categories)
{


string fileName = UIF.PromptLine ("Please enter the comp course with no spaces: ");
string categoryFileName = "categories_" + fileName + ".txt";
var reader = new StreamReader (categoryFileName);

string input = reader.ReadLine ();
string[] category = input.Split (',');
for (int i = 0; i < category.Length; i++)
category [i] = category [i].Trim ();

input = reader.ReadLine ();
string[] weights = input.Split (',');
for (i = 0; i < weights.Length; i++)
weights [i] = weights [i].Trim ();

input = reader.ReadLine ();
string[] number = input.Split (',');
for (i = 0; i < number.Length; i++)
number [i] = number [i].Trim ();

string studentFileName = "students_" + fileName + ".txt";

var reader2 = new StreamReader (studentFileName);
while (!reader2.EndOfStream) {
string student = reader2.ReadLine ();
int[] totalGrade = new int[category.Length];
string [] studentData = student.Split (',');
string studentFile = ("studentData[0]" + fileName + ".data");
var reader3 = new StreamReader (studentFile);
}



while (!reader3.EndOfStream) {
string grade = reader3.ReadLine ();
string [] gradeValue = grade.Split (',');
}





for (int i = 0; i < category.Length; i++) {
if (category [i].Trim ().StartsWith (code)) {
return i;


}
}
return -1;
{

int totalGrade = 0;
for (int i = 0; i < totalGrade.Length; i++){
totalGrade[i] = totalGrade[i]/number[i]*weights[i];
}

{

int totalGradeScore = 0;
int weightScore = 0;
for (int i = 0; i < totalGrade.Length; i++){
totalGradeScore += totalGrade [i];
weightScore += weights [i];
}



int avg;
avg = totalGradeScore/weightScore;

//writer.WriteLine avg = totalGradeScore/weightScore;
writer.WriteLine(avg);

writer.Close();
return avg;

}
}

}
}}}