In my database I have subjects. Each subject can have many exams, assignments and attendance. For each subject I am trying to find which exams have "examGradeAchieved" as NULL. (As in the exams the student does not have a result for yet)
If examGradeAchieved is set to null then I want to find the grade worth of that exam (another variable, for example one exam is worth 20% of the whole subject), add "ExamGradeWorth" to a list then find the sum of that list to equal the grade so that I can find the remaining potential marks the student can achieve in that subject. However it is displaying the wrong numbers. If examGradeAchieved is set to null it should display the 20% but it is displaying 0. Also for any subjects where there is no potential remaining marks it is displaying the total value of all the exams instead of displaying 0.
for(int i=0; i<subjects.size(); i++){ //for each subject in the list
Subject subject = subjects.get(i);
remExamMarks =0;
remAssignMarks = 0;
remAttenMarks = 0;
List<Exam> exams = subject.getExam();
for(int z=0; z<exams.size(); z++) {
Exam exam = exams.get(z);
ArrayList<Double> examRemMarks = new ArrayList<Double>();
if(exams.get(z).getExamGradeAchieved() !=null) {
examRemMarks.add(exams.get(z).getExamGradeWorth());
}
for(int h=0; h < examRemMarks.size(); h++) {
remExamMarks = remExamMarks + examRemMarks.get(h);
}
}
System.out.println(remExamMarks + "EXAM REM MARKS ==================");
Aucun commentaire:
Enregistrer un commentaire