diff --git a/BMI Calculator/index.html b/BMI Calculator/index.html new file mode 100644 index 0000000..5ab76d4 --- /dev/null +++ b/BMI Calculator/index.html @@ -0,0 +1,35 @@ + + + + + + + + + Document + + + +
+
+

BMI CALCULATOR

+
+

Height in meters

+ +
+
+

Weight in kilograms

+
+
+ +
+

ss

+

+
+
+ +
+ + + + \ No newline at end of file diff --git a/BMI Calculator/readme.md b/BMI Calculator/readme.md new file mode 100644 index 0000000..89f0695 --- /dev/null +++ b/BMI Calculator/readme.md @@ -0,0 +1,4 @@ +# BMI Calculator + +A simple calculator to find your body mass index. +Enter your height and weight in the fields and find how you doing. \ No newline at end of file diff --git a/BMI Calculator/script.js b/BMI Calculator/script.js new file mode 100644 index 0000000..bf19e15 --- /dev/null +++ b/BMI Calculator/script.js @@ -0,0 +1,27 @@ +var heightInput = document.querySelector(".height-input-field"); +var weightInput = document.querySelector(".weight-input-field"); +var calculateButton = document.querySelector(".calculate"); +var result = document.querySelector(".result"); +var statement = document.querySelector(".result-statement"); +var BMI, height, weight; + +calculateButton.addEventListener("click", () => { + + height = heightInput.value; + weight = weightInput.value; + BMI = (weight / (height ** 2)) * 10000; + result.innerText = "BMI : " + BMI.toFixed(2); + + if (height == "" || weight == "") { + statement.innerText = "Enter your height and weight"; + } + else if (BMI < 18.5) { + statement.innerText = "You are underweight !"; + } else if ((BMI > 18.5) && (BMI < 24.9)) { + statement.innerText = "You are normal :)"; + } else if ((BMI > 25) && (BMI < 29.9)) { + statement.innerText = "You are overweight !"; + } else { + statement.innerText = "You are obese !"; + } +}); \ No newline at end of file diff --git a/BMI Calculator/style.css b/BMI Calculator/style.css new file mode 100644 index 0000000..122f403 --- /dev/null +++ b/BMI Calculator/style.css @@ -0,0 +1,63 @@ +* { + padding: 0; + margin: 0; + box-sizing: border-box; + font-family: 'Courier New', Courier, monospace; +} + +*:focus { + outline: none; +} + +.body-wrapper { + display: flex; + width: 100%; + height: 100vh; + align-items: center; + justify-content: center; +} + +.calculator-container { + border: 1px solid black; + padding: 30px; + display: flex; + flex-direction: column; + align-items: center; +} + +.label { + font-size: 12px; + color: gray; +} + +.input-wrapper { + width: 100%; + margin: 5px; +} + +.calculator-container input { + width: 100%; + height: 30px; + border-radius: 6px; + border: 1px solid black; + padding-left: 5px; +} + +.calculator-container .calculate { + margin-top: 20px; + cursor: pointer; + width: 80%; + border: 1px solid black; + background-color: white; + padding: 10px 50px 10px 50px; +} + +.result-container { + margin-top: 10px; + height: 50px; + width: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-between; +} \ No newline at end of file