Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 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 _4.Average_Grades
  8. {
  9. class Student
  10. {
  11. public string FirstName { get; set; }
  12. public string SecondName { get; set; }
  13. public double Grade { get; set; }
  14. public Student(string firstName, string secondName, double grade)
  15. {
  16. this.FirstName = firstName;
  17. this.SecondName = secondName;
  18. this.Grade = grade;
  19. }
  20. public double getGrade()
  21. {
  22. return this.Grade;
  23. }
  24.  
  25. public override string ToString()
  26. {
  27. return string.Format(this.FirstName, this.SecondName, this.Grade);
  28. }
  29. }
  30.  
  31.  
  32. class Program
  33. {
  34. static void Main(string[] args)
  35. {
  36. List<Student> students = new List<Student>();
  37. int n = int.Parse(Console.ReadLine());
  38.  
  39. for (int i = 0; i < n; i++)
  40. {
  41. string[] info = Console.ReadLine().Split(" ");
  42. string firstName = info[0];
  43. string secondName = info[1];
  44. double grade = double.Parse(info[2]);
  45.  
  46. Student student = new Student(firstName, secondName, grade);
  47. students.Add(student);
  48. }
  49. students.OrderByDescending(t => t.Grade);
  50. foreach (Student student in students)
  51. {
  52. Console.WriteLine(student.ToString()) ;
  53. }
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement