Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions BMI Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>

<body>
<div class="body-wrapper">
<div class="calculator-container">
<h1>BMI CALCULATOR</h1>
<div class="input-wrapper">
<p class="label">Height in meters</p>
<input class="height-input-field" type="text">
</div>
<div class="input-wrapper">
<p class="label">Weight in kilograms</p>
<input class="weight-input-field" type="text"><br>
</div>
<button class="calculate"> Calculate</button>
<div class="result-container">
<h3 class="result">ss</h3>
<p class="result-statement"></p>
</div>
</div>

</div>
<script src="script.js"></script>
</body>

</html>
4 changes: 4 additions & 0 deletions BMI Calculator/readme.md
Original file line number Diff line number Diff line change
@@ -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.
27 changes: 27 additions & 0 deletions BMI Calculator/script.js
Original file line number Diff line number Diff line change
@@ -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 !";
}
});
63 changes: 63 additions & 0 deletions BMI Calculator/style.css
Original file line number Diff line number Diff line change
@@ -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;
}