Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 4. Average Grades
- Define a class Student, which holds the following information about students: name, list of grades and average grade (calculated property, read-only). A single grade will be in range [2…6], e.g. 3.25 or 5.50.
- Read a list of students and print the students that have average grade ≥ 5.00 ordered by name (ascending), then by average grade (descending). Print the student name and the calculated average grade.
- Examples
- Input Output
- 3
- Ivan 3
- Todor 5 5 6
- Diana 6 5.50 Diana -> 5.75
- Todor -> 5.33
- 6
- Petar 3 5 4 3 2 5 6 2 6
- Mitko 6 6 5 6 5 6
- Gosho 6 6 6 6 6 6
- Ani 6 5 6 5 6 5 6 5
- Iva 4 5 4 3 4 5 2 2 4
- Ani 5.50 5.25 6.00 Ani -> 5.58
- Ani -> 5.50
- Gosho -> 6.00
- Mitko -> 5.67
- Hints
- • Create class Student with properties Name (string), Grades (double[]), and property AverageGrade (calculated by LINQ as Grades.Average(), read-only).
- • Make a list of students and filter with LINQ all students that has average grade >= 5.00.
- • Print the filtered students ordered by name in ascending order, then by average grade in descending order.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement