Answer to Question #271097 in C# for nick

Question #271097

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


1
Expert's answer
2021-11-25T07:04:55-0500
    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; }
    }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS