← Java from Scratch
Lesson 33 of 88 · 10 XP
A task on classes
Theory and problem statement
Machine translation, not yet reviewed by a native speaker.
Let's put it all together: fields, a constructor, instance methods and a static method.
Task. A class Student: a name and an array of grades. Methods:
- double average() — the average grade;
- int best() — the best grade;
- static Student top(Student[] all) — the student with the highest average (on a tie — the one who comes first).
Input: n, then n lines of name grade grade …. Print each student as name: average (best)
(the average with 2 decimal places), then Best: name.
Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.