RGAlex

O1. Bonus Scoring System / O5. Mid Exam Retake

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