{"id":839,"date":"2024-05-09T10:45:00","date_gmt":"2024-05-09T10:45:00","guid":{"rendered":"https:\/\/worldseotool.com\/?page_id=839"},"modified":"2024-05-09T10:45:00","modified_gmt":"2024-05-09T10:45:00","slug":"bac-calculator","status":"publish","type":"page","link":"https:\/\/shoptips24.com\/tools\/bac-calculator\/","title":{"rendered":"BAC Calculator"},"content":{"rendered":"\n<style>\n    body {\n      font-family: Arial, sans-serif;\n      margin: 0;\n      padding: 0;\n      \n      justify-content: center;\n      align-items: center;\n     \n      background-color: #f4f4f4;\n    }\n\n    .calculator {\n      background-color: #fff;\n      padding: 20px;\n      border-radius: 8px;\n      box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n    }\n\n    .calculator h2 {\n      margin-top: 0;\n      margin-bottom: 20px;\n    }\n\n    label {\n      display: block;\n      margin-bottom: 5px;\n    }\n\n    input[type=\"text\"] {\n      width: 100%;\n      padding: 8px;\n      margin-bottom: 15px;\n      border: 1px solid #ccc;\n      border-radius: 4px;\n    }\n\n    input[type=\"button\"] {\n      background-color: #4caf50;\n      color: white;\n      padding: 10px 20px;\n      border: none;\n      border-radius: 4px;\n      cursor: pointer;\n    }\n\n    input[type=\"button\"]:hover {\n      background-color: #45a049;\n    }\n\n    #result {\n      margin-top: 20px;\n      font-weight: bold;\n    }\n  <\/style>\n<\/head>\n<body>\n  <div class=\"calculator\">\n    <h2>BAC Calculator<\/h2>\n    <label for=\"drinks\">Number of Drinks:<\/label>\n    <input type=\"text\" id=\"drinks\" placeholder=\"Enter number of drinks\">\n    <label for=\"weight\">Body Weight (in kg):<\/label>\n    <input type=\"text\" id=\"weight\" placeholder=\"Enter your weight\">\n    <label for=\"hours\">Hours Since First Drink:<\/label>\n    <input type=\"text\" id=\"hours\" placeholder=\"Enter hours\">\n    <input type=\"button\" value=\"Calculate\" onclick=\"calculateBAC()\">\n    <div id=\"result\"><\/div>\n  <\/div>\n\n  <script>\n    function calculateBAC() {\n      const drinks = parseFloat(document.getElementById('drinks').value);\n      const weight = parseFloat(document.getElementById('weight').value);\n      const hours = parseFloat(document.getElementById('hours').value);\n\n      if (!isNaN(drinks) && !isNaN(weight) && !isNaN(hours) && drinks > 0 && weight > 0 && hours >= 0) {\n        const gramsAlcohol = drinks * 14; \/\/ 14 grams of alcohol per standard drink\n        const bodyWater = weight * 1000 * 0.58; \/\/ 58% of body weight is water\n        const eliminationRate = 0.015; \/\/ Alcohol elimination rate per hour\n\n        let bac = (gramsAlcohol \/ (bodyWater * 10)) * 100 - (eliminationRate * hours);\n\n        if (bac < 0) {\n          bac = 0;\n        }\n\n        document.getElementById('result').innerHTML = `Estimated BAC: ${bac.toFixed(3)}%`;\n      } else {\n        document.getElementById('result').innerHTML = 'Please enter valid values.';\n      }\n    }\n  <\/script>\n","protected":false},"excerpt":{"rendered":"<p>BAC Calculator Number of Drinks: Body Weight (in kg): Hours Since First Drink:<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-839","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/shoptips24.com\/tools\/wp-json\/wp\/v2\/pages\/839","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shoptips24.com\/tools\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/shoptips24.com\/tools\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/shoptips24.com\/tools\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/shoptips24.com\/tools\/wp-json\/wp\/v2\/comments?post=839"}],"version-history":[{"count":0,"href":"https:\/\/shoptips24.com\/tools\/wp-json\/wp\/v2\/pages\/839\/revisions"}],"wp:attachment":[{"href":"https:\/\/shoptips24.com\/tools\/wp-json\/wp\/v2\/media?parent=839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}