Advertisement
veronikaaa86

01. Bonus Scoring System

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