Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Student
- {
- public List<int> Score { get; set; }
- public string Name { get; set; }
- }
- var students=new List<Student>
- {
- new Student {Name= "Jessi", Score= new List<int> {97, 72, 81, 60}},
- new Student {Name= "Jolle", Score= new List<int> {75, 84, 91, 39}},
- new Student {Name= "Penton",Score= new List<int> {88, 94, 65, 85}},
- new Student {Name= "Garcia",Score= new List<int> {97, 89, 85, 82}},
- new Student {Name= "Beebe", Score= new List<int> {35, 72, 88, 70}}
- };
- Console.WriteLine(" Type student name !");
- Console.WriteLine();
- while (true)
- {
- var IName = Console.ReadLine();
- double cont = 0;
- var score = students.Where(n => n.Name == IName ).Select(p => p.Score).FirstOrDefault();
- if (score == null)
- {
- Console.WriteLine("This Name does not Present in the collection.");
- }
- else
- {
- foreach (var i in score)
- {
- cont += i;
- Console.Write(" "+i+" ");
- }
- Console.WriteLine( $" \n"+cont / 4);
- Console.WriteLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement