Advertisement
ShadowEmbrace

Grade

Feb 12th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function grade(examPoints, homeworkPoints, totalHomework) {
  2.     let maxPoints = 100;
  3.     let totalPoints = (((examPoints * 100) / 400) * 0.9) + ((homeworkPoints * 100 / totalHomework) * 0.1);
  4.  
  5.     let grade = 3 + 2 * (totalPoints - maxPoints / 5) / (maxPoints / 2);
  6.  
  7.     if (examPoints === 400) {
  8.         console.log((6).toFixed(2));
  9.  
  10.     } else if (grade < 3) {
  11.         console.log((2).toFixed(2));
  12.     } else if (grade > 6) {
  13.         console.log((6).toFixed(2));
  14.     } else {
  15.         console.log(grade.toFixed(2));
  16.  
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement