Java1 SOL
Java1 SOL
1
ISSAE – CNAM Liban NFA035: Examen de rattrapage 2019-2020
FRANCAIS
EXERCICE 1: Collections
Pour gérer les notes des étudiants au CNAM on propose les trois classes suivantes :
// Méthodes à implémenter
Question 1. En utilisant la Map etudExamMAP, Ecrire une méthode getCreditsEtudiant qui prend en
paramètre un objet de type Etudiant et qui calcule le nombre total de crédits acquis par cet étudiant
(les examens réussis).
Question 2. En utilisant la Map coursExamMAP, Ecrire une méthode getMoyenneCours qui prend en
paramètre un objet de type Cours et qui calcule la moyenne générale de tous les étudiants de ce cours.
Question 3. En utilisant la Map coursExamMAP, Ecrire une méthode getPromusCours qui prend en
paramètre un objet de type Cours et qui compte le nombre d’étudiants promus dans ce cours.
Question 4. En utilisant la Map coursExamMAP, Ecrire une méthode getEchouesCours qui prend en
paramètre un objet de type Cours et qui compte le nombre d’étudiants échoués dans ce cours.
2
ISSAE – CNAM Liban NFA035: Examen de rattrapage 2019-2020
ENGLISH
EXERCISE 1: Collections
Question 1. Using the Map etudExamMAP, write a method getCreditsEtudiant that takes in parameter
an object of type Etudiant and calculates the total number of credits acquired by this student
(Successful exams only).
Question 2. Using the Map coursExamMAP, write a method getMoyenneCours that takes in parameter
an object of type Cours and calculates the general average of all students’ exams for that course.
Question 3. Using the Map coursExamMAP, write a method getPromusCours that takes in parameter an
object of type Cours and counts the number of students who succeed the exam of that course.
Question 4. Using the Map coursExamMAP, write a method getEchouesCours that takes in parameter an
object of type Cours and counts the number of students who fail the exam of that course.
3
ISSAE – CNAM Liban NFA035: Examen de rattrapage 2019-2020
Question 1. (5 ½ pts)
Solution
public int getCreditsEtudiant(Etudiant e) {
int sum = 0;
Set<Examen> exSET = etudExamMAP.get(e);
Iterator<Examen> exIt = exSET.iterator();
while(exIt.hasNext())
sum += exIt.next().cours.credits;
return sum; }
Question 2. (5 ½ pts)
Solution
public double getMoyenneCours(Cours c) {
double sum = 0;
Set<Examen> exSET = coursExamMAP.get(c);
Iterator<Examen> exIt = exSET.iterator();
while(exIt.hasNext())
sum += exIt.next().note;
return sum/exSET.size(); }
Question 3. (5 ½ pts)
Solution
public int getPromusCours(Cours c) {
int promus = 0;
Set<Examen> exSET = coursExamMAP.get(c);
Iterator<Examen> exIt = exSET.iterator();
while(exIt.hasNext())
if(exIt.next().note >= 10) promus++;
return promus; }
Question 4. (3 ½ pts)
Solution
public int getEchouesCours(Cours c) {
Set<Examen> exSET = coursExamMAP.get(c);
return exSET.size() - getPromusCours(c); }