Сначала в коде есть класс Student, в котором... ну, ученик создается с такими параметрами, как следовать:
String firstName, String LastName, int RegisterDiaryNumber.
Также методы равны, hashCode и toString переопределяются.
Затем класс Оценка создана и принимает в качестве параметра 8 int (всего 8 оценок)
Наконец, в main есть этот фрагмент кода:
Код: Выделить всё
public static void main (String[] args) {
Student student1 = new Student("Terry", "Pratchett", 2);
Student student2 = new Student("Arashi", "Ryuuno", 3);
Student student3 = new Student("Nobunaga", "Oda", 4);
Student student4 = new Student("Pheonix", "Wright", 5);
Student student5 = new Student("Ainz", "Gown", 1);
Grades student1Math = new Grades(4, 5, 4, 3, 2, 5, 5, 3);
Grades student2Math = new Grades(5, 6, 5, 5, 6, 5, 5, 4);
Grades student3Math = new Grades(3, 3, 5, 4, 3, 4, 5, 2);
Grades student4Math = new Grades(5, 4, 5, 3, 4, 5, 3, 5);
Grades student5Math = new Grades(4, 5, 5, 3, 3, 4, 6, 5);
Map mathGrades = new HashMap();
mathGrades.put(student1, student1Math);
mathGrades.put(student2, student2Math);
mathGrades.put(student3, student3Math);
mathGrades.put(student4, student4Math);
mathGrades.put(student5, student5Math);
for (Map.Entry entry : mathGrades.entrySet()){
System.out.println("Number " + entry.getKey() +" got grades as follow:" +entry.getValue());
System.out.println("Student average grade is: ");
}
}
Если хотите проверить весь код, затем проверьте ссылку ниже (это задание из учебного курса JAVA, в котором говорится: «С помощью HashMap создайте программу, которая будет хранить (личные) данные учащихся и их оценки. Программа должна показывать среднее значение) оценка каждого ученика."
Среднее значение может быть целым или двойным (округленным).
https://kodilla.com/pl/project-java/173235#
Подробнее здесь: https://stackoverflow.com/questions/638 ... ap-in-java
Мобильная версия