Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function creditSystem(input) {
- let n = Number(input[0]);
- let totalGrades = 0.0;
- let totalCredits = 0.0;
- for (let i = 1; i <= n; i++) {
- let number = Number(input[i]);
- let grade = number % 10;
- let credit = parseInt(number / 10);
- totalGrades += grade;
- if (grade == 2) {
- credit = 0;
- } else if (grade == 3) {
- credit *= 0.50;
- } else if (grade == 4) {
- credit *= 0.70;
- } else if (grade == 5) {
- credit *= 0.85;
- }
- totalCredits += credit;
- }
- console.log(`${totalCredits.toFixed(2)}\n${(totalGrades / n).toFixed(2)}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement