-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscript.js
37 lines (29 loc) · 1.09 KB
/
script.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
34
35
36
37
function calcular() {
var elementoAprov = document.getElementById("mediaDasNotas").value;
var elementoNota1 = document.getElementById("primeiraNota").value;
var elementoNota2 = document.getElementById("segundaNota").value;
var elementoNota3 = document.getElementById("terceiraNota").value;
var elementoNota4 = document.getElementById("QuartaNota").value;
var aprov = parseFloat(elementoAprov);
var n1 = parseFloat(elementoNota1);
var n2 = parseFloat(elementoNota2);
var n3 = parseFloat(elementoNota3);
var n4 = parseFloat(elementoNota4);
var media = ((n1 + n2 + n3 + n4) / 4).toFixed(2);
var txt = media + " ";
var passou;
if (media >= aprov) {
passou = "Congratulations, you've been approved!";
} else {
passou = "What a pity, you were disapproved...";
}
console.log(txt);
if (txt !== "NaN ") {
var mostrarElemento1 = document.getElementById("notareal");
mostrarElemento1.innerHTML = txt;
var mostrarElemento2 = document.getElementById("passou");
mostrarElemento2.innerHTML = passou;
} else {
alert("Complete all the fields correctly!");
}
}