<iframe>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BMI Calculator</title>
<style>
  body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f0f0f0;
  }
  .container {
    max-width: 500px;
    margin: 50px auto;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  }
  h1 {
    text-align: center;
    color: #333;
  }
  form {
    text-align: center;
  }
  input {
    width: 100px;
    padding: 8px;
    margin: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
  }
  select {
    padding: 8px;
    margin: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
  }
  button {
    padding: 10px 20px;
    background-color: #4caf50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
  }
  .result {
    text-align: center;
    margin-top: 20px;
  }
  .result span {
    font-size: 24px;
    font-weight: bold;
  }
  table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
  }
  th, td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #ddd;
  }
  th {
    background-color: #f2f2f2;
  }
</style>
</head>
<body>

<div class="container">
  <h1>BMI Calculator</h1>
  <form id="bmiForm">
    <input type="number" id="weight" placeholder="Weight">
    <select id="weightUnit">
      <option value="kg">Kilograms</option>
      <option value="g">Grams</option>
      <option value="lb">Pounds</option>
    </select>
    <input type="number" id="height" placeholder="Height">
    <select id="heightUnit">
      <option value="m">Meters</option>
      <option value="cm">Centimeters</option>
      <option value="ft">Feet</option>
      <option value="in">Inches</option>
    </select>
    <button type="button" onclick="calculateBMI()">Calculate</button>
  </form>
  <div class="result" id="result"></div>
  <table id="referenceTable">
    <thead>
      <tr>
        <th>BMI Range (kg/m<sup>2</sup>)</th>
        <th>BMI Range (lb/ft<sup>2</sup>)</th>
        <th>Category</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>&lt; 18.5</td>
        <td>&lt; 0.703</td>
        <td>Underweight</td>
      </tr>
      <tr>
        <td>18.5 - 24.9</td>
        <td>0.703 - 0.956</td>
        <td>Normal weight</td>
      </tr>
      <tr>
        <td>25 - 29.9</td>
        <td>0.957 - 1.106</td>
        <td>Overweight</td>
      </tr>
      <tr>
        <td>30 - 34.9</td>
        <td>1.107 - 1.286</td>
        <td>Obese I</td>
      </tr>
      <tr>
        <td>35 - 39.9</td>
        <td>1.287 - 1.473</td>
        <td>Obese II</td>
      </tr>
      <tr>
        <td>&ge; 40</td>
        <td>&ge; 1.474</td>
        <td>Obese III</td>
      </tr>
    </tbody>
  </table>
</div>

<script>
  function calculateBMI() {
    var weight = parseFloat(document.getElementById('weight').value);
    var height = parseFloat(document.getElementById('height').value);
    var weightUnit = document.getElementById('weightUnit').value;
    var heightUnit = document.getElementById('heightUnit').value;
    var bmi;

    if (weightUnit === 'g') {
      weight = weight / 1000;
    } else if (weightUnit === 'lb') {
      weight = weight * 0.453592;
    }

    if (heightUnit === 'cm') {
      height = height / 100;
    } else if (heightUnit === 'ft') {
      height = height * 0.3048;
    } else if (heightUnit === 'in') {
      height = height * 0.0254;
    }

    bmi = weight / (height * height);

    var resultElement = document.getElementById('result');
    resultElement.innerHTML = '<span>Your BMI: ' + bmi.toFixed(2) + '</span>';

    var referenceTable = document.getElementById('referenceTable');
    var category = '';

    if (bmi < 18.5) {
      category = 'Underweight';
      resultElement.style.color = '#ff0000';
    } else if (bmi >= 18.5 && bmi < 25) {
      category = 'Normal weight';
      resultElement.style.color = '#00ff00';
    } else if (bmi >= 25 && bmi < 30) {
      category = 'Overweight';
      resultElement.style.color = '#ffcc00';
    } else if (bmi >= 30 && bmi < 35) {
      category = 'Obese I';
      resultElement.style.color = '#ff6600';
    } else if (bmi >= 35 && bmi < 40) {
      category = 'Obese II';
      resultElement.style.color = '#ff3300';
    } else {
      category = 'Obese III';
      resultElement.style.color = '#ff0000';
    }

    resultElement.innerHTML += '<br><span>Category: ' + category + '</span>';
  }
</script>

</body>
</html></iframe>