Advertisement
Spocoman

01. Bonus Scoring System

Nov 3rd, 2023
561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function bonusScoringSystem(input) {
  2.     let students = Number(input[0]);
  3.     let lectures = Number(input[1]);
  4.     let bonus = Number(input[2]);
  5.     let attendances = [];
  6.  
  7.     for (let i = 3; i < students + 3; i++) {
  8.         attendances.push(Number(input[i]));
  9.     }
  10.  
  11.     console.log(`Max Bonus: ${(lectures > 0 ? Math.ceil(Math.max(...attendances) / lectures * (5 + bonus)) : 0)}.`);
  12.     console.log(`The student has attended ${(attendances.length > 0 ? Math.max(...attendances) : 0)} lectures.`);
  13.     return;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement