Advertisement
Ronka

Untitled

Jun 21st, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 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 ConsoleApp4
  8. {
  9. class Program
  10. {
  11. class Student
  12. {
  13. public string Name { get; set; }
  14. public List<double> grades { get; set; }
  15. public double averageGrade { get; set; }
  16. }
  17.  
  18. static void Main(string[] args)
  19. {
  20. var count = int.Parse(Console.ReadLine());
  21.  
  22. var excellentStudents = new List<Student>();
  23. for (int i = 0; i < count; i++)
  24. {
  25. string[] input = Console.ReadLine().Split().ToArray();
  26.  
  27. Student std = new Student();
  28. std.Name = input[0];
  29.  
  30. for (int j = 1; j < input.Length; j++)
  31. {
  32. std.grades.Add(Convert.ToDouble(input[j]));
  33. }
  34.  
  35. std.averageGrade = std.grades.Average();
  36.  
  37. if (std.averageGrade >= 5.00)
  38. {
  39. excellentStudents.Add(std);
  40. }
  41. }
  42.  
  43. excellentStudents = excellentStudents.OrderBy(x => x.Name).ThenByDescending(x => x.averageGrade).ToList();
  44.  
  45. foreach(Student ex in excellentStudents)
  46. {
  47. Console.WriteLine($"{ex.Name} -> {ex.averageGrade}");
  48. }
  49.  
  50.  
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement