Guest User

Bonus Scoring System

a guest
Feb 5th, 2021
1,357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(arr) {
  2.     let studentsCount = Number(arr.shift());
  3.     let allLectures = Number(arr.shift());
  4.     let initialBonus = Number(arr.shift());
  5.     let maxAtt = 0;
  6.     let maxBonus = 0;
  7.     for (let i = 0; i < studentsCount; i++) {
  8.         let attendances = arr[i];
  9.         let bonus = (attendances / allLectures) * (5 + initialBonus);
  10.         if (bonus >= maxBonus) {
  11.             maxBonus = bonus;
  12.             maxAtt = attendances;
  13.         }
  14.     }
  15.     console.log(`Max Bonus: ${Math.ceil(maxBonus)}.`);
  16.     console.log(`The student has attended ${maxAtt} lectures.`);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment