A Calculadora

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Calculadora de IMC</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 40px;
        }
        label, input {
            margin-top: 10px;
        }
        .result {
            margin-top: 20px;
            font-size: 20px;
        }
    </style>
</head>
<body>
    <h1>Calculadora de IMC</h1>
    <p>Insira seu peso em quilogramas e altura em metros para calcular seu IMC.</p>
    <label for="weight">Peso (em kg):</label>
    <input type="number" id="weight" required>
    <br>
    <label for="height">Altura (em metros):</label>
    <input type="number" id="height" step="0.01" required>
    <br>
    <button onclick="calculateBMI()">Calcular IMC</button>
    <div class="result" id="result"></div>

    <script>
        function calculateBMI() {
            var weight = document.getElementById("weight").value;
            var height = document.getElementById("height").value;
            var bmi = weight / (height * height);
            var resultText = "Seu IMC é: " + bmi.toFixed(2);

            if (bmi < 18.5) {
                resultText += " - Abaixo do peso";
            } else if (bmi >= 18.5 && bmi <= 24.9) {
                resultText += " - Peso normal";
            } else if (bmi >= 25 && bmi <= 29.9) {
                resultText += " - Sobrepeso";
            } else {
                resultText += " - Obesidade";
            }

            document.getElementById("result").innerText = resultText;
        }
    </script>
</body>
</html>