Advertisement
NelIfandieva

StudentsAverageGrade_ToAddMethods

Feb 15th, 2020
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. int n = int.Parse(Console.ReadLine());
  2.             Student[] allStudents = new Student[n];
  3.  
  4.             for (int i = 1; i <= n; i++)
  5.             {
  6.                 string input = Console.ReadLine();
  7.  
  8.                 string[] arr = input
  9.                     .Split(' ', StringSplitOptions.RemoveEmptyEntries);
  10.  
  11.                 string name = arr[0];
  12.  
  13.                 Student student = new Student(name);
  14.  
  15.                 for (int j = 1; j < arr.Length; j++)
  16.                 {
  17.                     double current = double.Parse(arr[j]);
  18.                     Grade grage = new Grade(current);
  19.                     student.Grades.Add(grage);
  20.                 }
  21.  
  22.                 allStudents[i - 1] = student;
  23.             }
  24.  
  25.             foreach(var stud in allStudents.OrderBy(s => s.Name).ThenByDescending(s => s.GardesAverage))
  26.             {
  27.                 if(stud.GardesAverage >= 5.00)
  28.                 {
  29.                     Console.WriteLine($"{stud.Name} -> {stud.GardesAverage:f2}");
  30.                 }
  31.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement