Advertisement
veronikaaa86

01. Bonus Scoring System

Oct 18th, 2021
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. package examPreparation;
  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 countStudents = Integer.parseInt(scanner.nextLine());
  10. int countLectures = Integer.parseInt(scanner.nextLine());
  11. int initBonus = Integer.parseInt(scanner.nextLine());
  12.  
  13. double maxBonus = Integer.MIN_VALUE;
  14. int maxAttendances = 0;
  15. for (int i = 0; i < countStudents; i++) {
  16. int attendances = Integer.parseInt(scanner.nextLine());
  17.  
  18. double currentBonus = attendances * 1.0 / countLectures * (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.", maxAttendances);
  28. }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement