Liliana797979

bonus scoring system - mid exam - fundamentals

Jun 28th, 2021
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function bonusScore(input) {
  2.     let studentsCount = Number(input.shift());
  3.     //console.log(studentsCount);
  4.     let lecturesCount = Number(input.shift());
  5.     //console.log(lecturesCount);
  6.     let bonus = Number(input.shift());
  7.     //console.log(bonus);
  8.     let highestScore = 0;
  9.     let totalBonus = 0;
  10.     for (let i = 0; i < studentsCount; i++) {
  11.         let student = Number(input[i]);
  12.         //console.log(student);
  13.         if (student <= lecturesCount) {
  14.             if (student > highestScore) {
  15.                 highestScore = student;
  16.             totalBonus = Math.ceil(highestScore / lecturesCount) * (5 + bonus);
  17.  
  18.             }
  19.         }
  20.     }
  21.     console.log(`Max Bonus: ${totalBonus}.`);
  22.     console.log(`The student has attended ${highestScore} lectures.`);
  23. }
  24.  
  25.  
  26. bonusScore([
  27.     '5',  '25', '30',
  28.     '12', '19', '24',
  29.     '16', '20'
  30.   ]);
Advertisement
Add Comment
Please, Sign In to add comment