public void processTask2() { Console.WriteLine("Result of the query: "); List <Structures.Student> list = Adapter.StudentInfoAdapter.students; list = list.Where(stud => stud.scholarship == 0).ToList(); var result = list.Select(stud => new { Student = stud, average = (stud.mathematicsMark + stud.informaticsMark + stud.physicsMark) / 3.0 }); int k = 0; Console.WriteLine("Number Name Surname Patronymic Average mark"); foreach (var val in result) { k++; Structures.Student student = val.Student; Console.WriteLine($"{k, -11}{student.firstName, -9}{student.surName, -12}{student.patronymic, -17}{val.average:f1}"); } Console.WriteLine(new string('-', 61)); }
public void processTask2() { StringBuilder sb = new StringBuilder(); sb.AppendLine("Result of the query: "); Console.WriteLine("Result of the query: "); List <Structures.Student> list = Adapter.StudentInfoAdapter.students; list = list.Where(stud => stud.mathematicsMark <= 2 || stud.informaticsMark <= 2 || stud.physicsMark <= 2 && stud.scholarship != 0).ToList(); var result = list.Select(stud => new { Student = stud }); int k = 0; sb.AppendLine("Number Surname Mathematics Informatics Physics Scholarship(edited)"); foreach (var val in result) { k++; Structures.Student student = val.Student; sb.AppendLine($"{k,-11}{student.surName,-12}{student.mathematicsMark,-16}{student.informaticsMark,-16}{student.physicsMark,-12}{0, -10}"); Console.WriteLine($"{k,-11}{student.surName,-12}{student.mathematicsMark,-16}{student.informaticsMark,-16}{student.physicsMark,-12}{0,-10}"); } sb.AppendLine(new string('=', 61)); Console.WriteLine(new string('=', 61)); writeToFile(sb.ToString()); }