-
Notifications
You must be signed in to change notification settings - Fork 2
/
1040.js
33 lines (26 loc) · 858 Bytes
/
1040.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const input = require("fs").readFileSync("./dev/stdin", "utf8");
let lines = input.split("\n");
let notas = lines.shift().split(" ");
let exame = lines.shift();
let valuesParse = notas.map(function (x) {
return parseFloat(x);
});
let [N1, N2, N3, N4] = valuesParse;
let media = (N1 * 2 + N2 * 3 + N3 * 4 + N4 * 1) / 10;
console.log(`Media: ${media.toFixed(1)}`);
if (media >= 7.0) {
console.log("Aluno aprovado.");
} else if (media < 5.0) {
console.log("Aluno reprovado.");
} else if (media >= 5.0 && media <= 6.9) {
console.log("Aluno em exame.");
exame = parseFloat(exame);
console.log(`Nota do exame: ${exame.toFixed(1)}`);
media = (exame + media) / 2;
if (media >= 5.0) {
console.log("Aluno aprovado.");
} else if (media <= 4.9) {
console.log("Aluno reprovado.");
}
console.log(`Media final: ${media.toFixed(1)}`);
}