You are on page 1of 2

Mohammad Mohsen Qubaia

32119001088

CODE:
i.Public void Method called FindBest that find the student with maximum marks(Mid+Part+Final)

public void FindBest(ArrayList<Student> Data) {

Student bestStudent = null;

double bestLevel = Double.MIN_VALUE;

for (Student s : Data) {

double level = s.getMidtermScore() + s.getParticipationScore() + s.getFinalScore();

if (level > bestLevel) {

bestLevel = level;

bestStudent = s;

if (bestStudent != null) {

System.out.println("The student with the highest level is: " + bestStudent.getName() + " with a level
of " + bestLevel);

} else {

System.out.println("This student is not among the best students");

}
j. Public void Method called FindAvg that find the average values for mid , final and Part.

public void FindAvg(ArrayList<Student> Data) {

double Mid_S = 0; //S=sum

double Participation_S = 0;

double Final_S = 0;

for (Student s :Data) {

Mid_S += s.getMidtermScore();

Participation_S += s.getParticipationScore();

Final_S += s.getFinalScore();

double Mid_Avg = Mid_S / Data.size();

double Participation_Avg = Participation_S / Data.size();

double Final_Avg = Final_S / Data.size();

System.out.println("The Average Midterm= " + Mid_Avg);

System.out.println("The Average Participation = " + Participation_Avg);

System.out.println("The Average Final =" + Final_Avg);

You might also like