Created
May 13, 2022 01:09
-
-
Save ermogenes/2378d4155c0f21291ce293b93e726e96 to your computer and use it in GitHub Desktop.
Aula 12/05 - Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<h1>Exercício Media4Notas</h1> | |
<script src="index.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const n1 = Number(prompt("Nota 1:")); | |
const n2 = Number(prompt("Nota 2:")); | |
const n3 = Number(prompt("Nota 3:")); | |
const n4 = Number(prompt("Nota 4:")); | |
let algumNumeroInvalido = | |
n1 < 0 || n1 > 10 || | |
n2 < 0 || n2 > 10 || | |
n3 < 0 || n3 > 10 || | |
n4 < 0 || n4 > 10; | |
if (algumNumeroInvalido) { | |
alert("Digite somente números entre 0.0 e 10.0."); | |
} else { | |
const media = (n1 + n2 + n3 + n4) / 4; | |
let resultado; | |
if (media < 5) { | |
resultado = "Reprovado"; | |
} else if (media < 6) { | |
resultado = "Em recuperação"; | |
} else { | |
resultado = "Aprovado"; | |
} | |
alert(`Você ficou com média ${media}. Resultado: ${resultado}`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment