THINK FIRST·CODE LATER

← All labs

ArrayList of students

Problem

Write a class Student with private fields name and grade (int), a constructor, getName(), getGrade() and toString() returning name (grade).

StudentList reads a count n, then n pairs name grade (the name is one word), stores the students in an ArrayList<Student>, and prints:

Students: 3
Best: Amina (91)
Above average: 1

(With 91, 78 and 84 the average is 84.33, so only one student is strictly above it.)

Best is the student with the highest grade, Above average counts the students whose grade is strictly greater than the average.

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.