01.Bonus Scoring System

Test #6 (Runtime error) Time used: 0.052 s Memory used: 1.13 MB
mail@pastecode.io avatar
unknown
java
3 years ago
1.2 kB
2
Indexable
Never
package softuni;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public MidExam01  {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int students = Integer.parseInt(sc.nextLine());
        int lectures = Integer.parseInt(sc.nextLine());
        int initialBonus = Integer.parseInt(sc.nextLine());
        List<Integer> studentAttendList = new ArrayList<>();
        List<Double> bonuses = new ArrayList<>();

        for (int i = 0; i < students ; i++) {
            int attendances = Integer.parseInt(sc.nextLine());
            studentAttendList.add(attendances);
            double totalBonus = (studentAttendList.get(i)/(double)lectures) * (5 + initialBonus);
            bonuses.add(totalBonus);
        }
        double max = bonuses.stream().max(Comparator.naturalOrder()).get();
        System.out.printf("Max Bonus: %.0f.\n",max);
        for (int j = 0; j < students; j++) {
            if(bonuses.get(j) == max){
                System.out.printf("The student has attended %d lectures.", studentAttendList.get(j));
            }
        }



    }
}