-
Notifications
You must be signed in to change notification settings - Fork 0
/
media.js
58 lines (45 loc) · 1.94 KB
/
media.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
Calcule a média da estudante, em seguida, com base na nota exiba as seguintes
frases:
1. Se a nota for 0, mostre na tela: "Infelizmente você zerou a prova :( "
2. Se a nota for entre 0.1 e 3, mostre na tela:
"Caramba, deu ruim, você obteve media {nota}! Estude mais e tente novamente!"
3. Se a nota for entre 3.1 e 5.9, mostre na tela:
"Você obteve media {nota}! Falta pouco para a média."
4. Se a nota for entre 6 e 7, mostre na tela: "Você está na média com {nota}"
5. Se a nota for entre 7.1 e 9.9, mostre na tela: "Notão! Sua média é {nota}!"
6. Se a nota for entre 10, mostre na tela:
"Hoje é seu aniversário? Pq você ta de parabéns! 10 de média"
*/
const botaoMedia = document.getElementById("btnSituacao")
const situacaoAluna = document.createElement('p')
const divMedias = document.getElementById("contentCalcMedias")
divMedias.appendChild(situacaoAluna)
function calcularMedia() {
const nota1 = parseFloat(document.getElementById('nota1').value)
const nota2 = parseFloat(document.getElementById('nota2').value)
const nota3 = parseFloat(document.getElementById('nota3').value)
const nota4 = parseFloat(document.getElementById('nota4').value)
let media =(nota1+nota2+nota3+nota4)/4
let mensagem = ""
if (media === 0 ){
mensagem ="Infelizmente você zerou a prova :( "
}
else if (media >= 0.1 && media <= 3){
mensagem = `Caramba, deu ruim, você obteve media ${media}! Estude mais e tente novamente!`
}
else if (media >= 3.1 && media <= 5.9){
mensagem = `Você obteve media ${media}! Falta pouco para a média`
}
else if (media >= 6 && media <= 7){
mensagem = `Você está na média com ${media}`
}
else if (media >= 7.1 && media <= 9.9){
mensagem = `Notão! Sua média é ${media}`
}
else if (media >=10){
mensagem = "Hoje é seu aniversário? Pq você ta de parabéns! 10 de média"
}
situacaoAluna.innerText = mensagem
}
botaoMedia.addEventListener('click', calcularMedia)