record Student(String name, int grade, int score) {}

/// Returns the record for a named student, or null if there is none.
Student findStudent(ArrayList<Student> students, String name) {
    for (Student student : students) {
        if (student.name().toLowerCase().equals(name.toLowerCase())) {
            return student;
        }
    }
    return null;
}

void main() {
    ArrayList<Student> students = new ArrayList<>(List.of(
            new Student("Ada", 9, 88),
            new Student("Grace", 10, 92),
            new Student("Alan", 9, 45),
            new Student("Katherine", 11, 95)));

    Student found = findStudent(students, "grace");
    if (found != null) {
        IO.println(found.name() + " is in grade " + found.grade() + ".");
    } else {
        IO.println("Not found.");
    }
}

// From Groundwork, chapter 10 (ch10-records), box 11.
// This example is from Groundwork, licensed CC BY-NC-SA 4.0.
// Run with: java ch10_11.java
