Advertisement
martinvalchev

Average_Grades

Feb 18th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Average_Grades
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             List<Student> ourCllass = new List<Student>();
  15.            
  16.             for (int i = 0; i < n; i++)
  17.             {
  18.                 List<string> input = Console.ReadLine().Split(' ').ToList();
  19.                 Student student = new Student();
  20.                 student.Name = input[0];
  21.                 input.RemoveAt(0);
  22.                 student.Grade = input.Select(double.Parse).ToList();
  23.                 ourCllass.Add(student);
  24.             }
  25.  
  26.             foreach (var person in ourCllass.Where(x =>x.AvarageGreade >= 5).OrderBy(x => x.Name).ThenByDescending(x=>x.AvarageGreade))
  27.             {
  28.                 Console.WriteLine($"{person.Name} -> {person.AvarageGreade:F2}");
  29.             }
  30.         }
  31.     }
  32.  
  33.     class Student
  34.     {
  35.         public string Name { get; set; }
  36.         public List<double> Grade { get; set; }
  37.         public double AvarageGreade { get { return Grade.Average(); } }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement