I have a problem with understanding the whole structure and I do not know how to get the average grades of students and how to calculate them
class Grades {
int grade1;
int grade2;
int grade3;
int grade4;
int grade5;
int grade6;
int grade7;
public Grades(int grade1, int grade2, int grade3, int grade4, int grade5, int grade6, int grade7) {
this.grade1 = grade1;
this.grade2 = grade2;
this.grade3 = grade3;
this.grade4 = grade4;
this.grade5 = grade5;
this.grade6 = grade6;
this.grade7 = grade7;
}
public int getGrade1() {
return grade1;
}
@Override
public String toString() {
return grade1 + ", " + grade2 + ", " + grade3 + ", " + grade4 + ", " + grade5 + ", " + grade6 + ", " + grade7;
}
}
public class ObjectsTestetON {
public static void main(String[] args) {
Student student1 = new Student("Ania", "Nowak", "00001");
Student student2 = new Student("Marcin", "Kasprzak", "00002");
Student student3 = new Student("Kasia", "Siodłak", "00003");
Student student4 = new Student("Błażej", "Markowski", "00004");
Grades grad1 = new Grades(5, 4, 5, 4, 5, 5, 4);
Grades grad2 = new Grades(3, 4, 5, 4, 3, 4, 4);
Grades grad3 = new Grades(4, 4, 5, 4, 4, 5, 4);
Grades grad4 = new Grades(2, 4, 3, 4, 3, 2, 3);
Map<Student, Grades> gradesParameter = new HashMap<>();
gradesParameter.put(student1, grad1);
gradesParameter.put(student2, grad1);
gradesParameter.put(student3, grad1);
gradesParameter.put(student4, grad1);
//generally i don't know how to construct this :(
// to get avearge value for every student grades
for (Grades i : gradesParameter.keySet()) { // :(
System.out.println("key: " + i + " value: " + gradesParameter.get(i)); // :(
}
}
}
I did it as it was in my course generally every grades1, 2 etc you could assign a specific name like test card homework or other but I did not do it I left it as an assessment 1 2 3 4 .. everything can be done in several ways and this is probably not very effective for this type of issue normally you could use different indicators in this example average grades without grades from homework etc but it was not important I modeled only like example