Advertisement
Guest User

Untitled

a guest
May 18th, 2021
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. package bgstudents;
  2. import java.util.*;
  3.  
  4. public class main {
  5.     public static void main(String[] args) {
  6.         Scanner Input = new Scanner(System.in);
  7.         int NumberOfStudents = Integer.parseInt(Input.nextLine());
  8.         int CountOfTheLectores = Integer.parseInt(Input.nextLine());
  9.         int BonusPoints = Integer.parseInt(Input.nextLine());
  10.         Map <Integer,Double> Bonuses = new HashMap<>();
  11.         Bonuses.put(0, 0.00);
  12.         for(int i=1; i<=NumberOfStudents; i++) {
  13.             int AttendceOfStudents = Integer.parseInt(Input.nextLine());
  14.             double TotalBonus = (double)AttendceOfStudents / CountOfTheLectores * (5 + BonusPoints);
  15.             Bonuses.put(AttendceOfStudents, TotalBonus);
  16.         }
  17.          Map.Entry<Integer, Double> Max = Bonuses.entrySet().stream()
  18.                 .max((a,b)->a.getValue().compareTo(b.getValue()))
  19.                  .get();
  20.  
  21.         System.out.printf("Max Bonus: %.0f.\nThe student has attended %s lectures.",Math.ceil(Max.getValue()),Max.getKey());
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement