Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html>

<head>
  <title> Imersão Dev Alura - Calculadore de média</title>
</head>

<body>
  <div class="container">
    <h1 class="page-title">
      Calculadora de média escolar</h1>
    <p class="page-subtitle">
      <b> Descubra a média de suas notas! <br>
        <div>
          <label for="nome">Nome do Aluno</label><br>
          <input class="nomeAluno" type="string" id="nome" size="20" /><br>

          <label for="nota1">Nota 1° bimestre</label><br>
          <input type="number" id="nota1" size="2" /><br>
          <label for="nota2">Nota 2° bimestre</label><br>
          <input type="number" id="nota2" size="2" /><br>
          <label for="nota3">Nota 3° bimestre</label><br>
          <input type="number" id="nota3" size="2" /><br>
          <label for="nota4">Nota 4° bimestre</label><br>
          <input type="number" id="nota4" size="2" /><br>
          <button type="submit" onclick="Converter()">Calcular</button>
          <p class="avaliacao" id="mediaFinal">
          </p>
          <p class="avaliacao" id="aprovacaoFinal">
          </p>
        </div>
    </p>
  </div>
  <img src="https://www.alura.com.br/assets/img/imersoes/dev-2021/logo-imersao-conversor-de-moedas.svg" class="page-logo" alt="">
  <a href="https://alura.com.br/" target="_blank">
    <img src="https://www.alura.com.br/assets/img/home/alura-logo.svg" alt="" class="alura-logo">
  </a>
</body>

</html>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Patrick+Hand&display=swap");

body {
  font-family: "Patrick Hand", cursive;
  font-size: 25px;
  min-height: 400px;
  background-image: url("https://cdn.pixabay.com/photo/2014/04/02/17/04/green-307835_960_720.png");
  background-color: #000000;
  background-size: 150vh;
  background-position: center top;
  background-repeat: no-repeat;
  margin-top: 10px;
}

label {
  color: #d3d3d3;
}

input {
  background: #d3d3d3;
  width: 50px;
}

button {
  background: #000000;
  color: #ffffff;
}

.container {
  text-align: center;
  padding: 20px;
  height: 100vh;
}

.page-title {
  color: #d3d3d3;
  margin: 30px 0 0px;
}

.page-subtitle {
  color: #d3d3d3;
  margin-top: 0px;
}

.page-logo {
  width: 60px;
  position: absolute;
  top: 130px;
  right: 10px;
}

.alura-logo {
  width: 40px;
  position: absolute;
  top: 100px;
  right: 10px;
}

.nomeAluno {
  color: #000000;
  width: 200px;
}

.avaliacao {
  background: #000000;
  border-radius: 12px;
  text-align: center top;
  color: #d3d3d3;
  font-size: 28px;
}

              
            
!

JS

              
                function Converter() {
  // Obter nome do aluno
  var elementoNome = document.getElementById("nome");

  var nome = elementoNome.value;

  // Pedir notas e armazenar
  var elementoPrimeiroBimestre = document.getElementById("nota1");

  var nota1 = elementoPrimeiroBimestre.value;
  var notaPrimeiroBimestre = parseFloat(nota1);

  var elementoSegundoBimestre = document.getElementById("nota2");

  var nota2 = elementoSegundoBimestre.value;
  var notaSegundoBimestre = parseFloat(nota2);

  var elementoTerceiroBimestre = document.getElementById("nota3");

  var nota3 = elementoTerceiroBimestre.value;
  var notaTerceiroBimestre = parseFloat(nota3);

  var elementoQuartoBimestre = document.getElementById("nota4");

  var nota4 = elementoQuartoBimestre.value;
  var notaQuartoBimestre = parseFloat(nota4);

  // calcular media final
  var notaFinal =
    (notaPrimeiroBimestre +
      notaSegundoBimestre +
      notaTerceiroBimestre +
      notaQuartoBimestre) /
    4;

  // arredondar 1 casa decimal
  var notaFixada = notaFinal.toFixed(1);

  // checar media no console
  console.log(notaFixada);
  var mediaFinal = document.getElementById("mediaFinal");
  var exibicaoFinal = "Sua média final é " + notaFixada;

  // exibir no html (troca de valores)
  mediaFinal.innerHTML = exibicaoFinal;

  // Condição de aprovado
  var aprovacaoFinal = document.getElementById("aprovacaoFinal");

  if (notaFixada >= 7)
    var exibicaoFinal = nome + ", você foi aprovado, parabéns!";
  else
    var exibicaoFinal =
      nome + ", você foi reprovado, não desanime e tente outra vez!";

  // checar condicao no console
  console.log(exibicaoFinal);
  // exibir no html
  aprovacaoFinal.innerHTML = exibicaoFinal;

  // limpar campo Insira seu endereço
  document.getElementById("nome").value = "";
  document.getElementById("nota1").value = "";
  document.getElementById("nota2").value = "";
  document.getElementById("nota3").value = "";
  document.getElementById("nota4").value = "";
}

              
            
!
999px

Console