Create a console application which can be used to read in and do some calculations on marks.
Open the file Marks.dat, review this file and take note of the following:
Each line of the file is representing the details for a specific student, namely: student number, name, quiz average, prac average and test mark
Your application should read in the details from the file, create a student object for each student and add the objects to a list of students
class Program
{
const string fileName = "Marks.dat";
static void Main(string[] args)
{
List<Student> collection = File.ReadAllLines(fileName).Select((line) =>
{
var values = line.Split(',');
return new Student()
{
Number = int.Parse(values[0]),
Name = values[1],
QuizAverage = double.Parse(values[2]),
PracAverage = double.Parse(values[3]),
TestMark = double.Parse(values[4])
};
}).ToList();
}
}
class Student
{
public string Name { get; set; }
public int Number { get; set; }
public double QuizAverage { get; set; }
public double PracAverage { get; set; }
public double TestMark { get; set; }
}
Comments
Leave a comment