Didart

Bonus Scoring System

Oct 18th, 2021
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.List;
  3. import java.util.Scanner;
  4. import java.util.stream.Collectors;
  5.  
  6. public class BonusScoringSystem {
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.  
  10.         int countStudents = Integer.parseInt(scanner.nextLine());
  11.         int countLectures = Integer.parseInt(scanner.nextLine());
  12.         int initBonus = Integer.parseInt(scanner.nextLine());
  13.  
  14.         double maxBonus = 0;
  15.         int maxAttendance = 0;
  16.         for (int i = 0; i < countStudents; i++) {
  17.             int attendance = Integer.parseInt(scanner.nextLine());
  18.  
  19.             double currentBonus = attendance * 1.0 / countLectures * (5 + initBonus);
  20.  
  21.             if (currentBonus > maxBonus) {
  22.                 maxBonus = currentBonus;
  23.                 maxAttendance = attendance;
  24.             }
  25.         }
  26.         System.out.printf("Max Bonus: %.0f.%n", Math.ceil(maxBonus));
  27.         System.out.printf("The student has attended %d lectures.", maxAttendance);
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment