Advertisement
Rayk

Bonus Scoring System

Jul 13th, 2020
732
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. package Test;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class First {
  6.     public static void main(String[] args) {
  7.         Scanner scan = new Scanner(System.in);
  8.         int n = Integer.parseInt(scan.nextLine());
  9.         int lectures = Integer.parseInt(scan.nextLine());
  10.         int initialBonus = Integer.parseInt(scan.nextLine());
  11.         double maxBonus = 0;
  12.         int maxLectures = 0;
  13.         for (int i = 0; i < n; i++) {
  14.             int attendance = Integer.parseInt(scan.nextLine());
  15.             double currentBonus = ((attendance * 1.0) / lectures) * (5 + (initialBonus));
  16.             if (currentBonus > maxBonus){
  17.                 maxBonus = currentBonus;
  18.                 maxLectures = attendance;
  19.             }
  20.         }
  21.         int bonus = (int) Math.round(maxBonus);
  22.         System.out.println("Max Bonus: " + bonus + ".");
  23.         System.out.printf("The student has attended %d lectures.", maxLectures);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement