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
48 changes: 35 additions & 13 deletions simple calculator/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<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">
<title>BMI Calculator</title>
</head>
<body>
<form action="/bmicalculator" method="post">
<h1>BMI Calculator</h1>
<input type="text" name="ht" placeholder="enter body height">
<input type="text" name="wt" placeholder="enter body weight">
<button type="submit" name="button">Calculate BMI</button>
</form>
</body>
</html>
<link rel="stylesheet" href="style.css">
<script src="index.js" defer></script>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link rel="icon" href="https://res.cloudinary.com/djww0nfoy/image/upload/v1666812816/web%20dev/favicon_w2a821.ico">
<link href="https://fonts.googleapis.com/css2?family=Akaya+Telivigala&display=swap" rel="stylesheet">
</head>
<body>
<div class="container">
<h1>BMI Calculator</h1>
<label>
<input id="h-input" type="number" placeholder="Enter Your Height ">
</label>
<label>
<input id="w-input" type="number" placeholder="Enter Your Weight ">
</label>
<button type="submit" onclick="Calculate()">Calculate BMI</button>

<div class="bmi-value">
<h4>BMI Value: </h4>
<div id="bmi-output"></div>
</div>
<div class="status">
<h4>Status: </h4>
<div id="bmi-status"></div>
</div>
</div>

</body>
</html>
24 changes: 24 additions & 0 deletions simple calculator/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function Calculate(){
var height = document.getElementById("h-input").value;
var weight = document.getElementById("w-input").value;

var result = parseFloat(weight) /(parseFloat(height)/100)**2;

// var result = weight/(height ** 2);

if(!isNaN(result)){
document.getElementById("bmi-output").innerHTML = result;
if(result < 18.5 ){
document.getElementById("bmi-status").innerHTML = "Underweight";
}
else if(result > 18.5 && result < 25){
document.getElementById("bmi-status").innerHTML = "Healthy";
}
else if( result > 25 && result < 30){
document.getElementById("bmi-status").innerHTML = "Overweight";
}
else{
document.getElementById("bmi-status").innerHTML = "Obesity";
}
}
}
140 changes: 70 additions & 70 deletions simple calculator/main.css → simple calculator/style.css
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
*{margin: 0; padding: 0;font-family: 'Old Standard TT', serif;}
.container{
display: grid;
justify-content: center;
align-content: center;
min-height: 100vh;
grid-template-columns: 30vw;
grid-template-rows: repeat(3,10vh) 5vh repeat(2,10vh);
grid-gap: 10px;
}
body{
background: rgb(37, 31, 31);
}
h1{
text-align: center;
color: white;
}
.submit-btn{
background-color: rgb(141, 64, 224);
}
.bmi-value{
background-color: rgb(51, 255, 0);
display: grid;
grid-template-rows: 50% 50%;
}
.status{
background-color: rgb(255, 127, 191);
display: grid;
grid-template-rows: 50% 50%;
}
.container > div{
padding: 10px;
font-size: 20px;
font-weight: bold;
color: black;
border-radius: 10px;
}
button,input{
min-width: 100%;
min-height: 100%;
border: none;
outline: none;
font-size: 1.5vw;
border-radius: 8px;
}
input{
background: #e4b659;
text-indent: 0.5em;
max-width:100% ;
color: black;
outline: none;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
input[type=number] {
-moz-appearance: textfield;
}
button{
background: tomato;
cursor: pointer;
}
button:hover{
background: #c70039;
color: white;
*{margin: 0; padding: 0;font-family: 'Akaya Telivigala', cursive;}
.container{
display: grid;
justify-content: center;
align-content: center;
min-height: 100vh;
grid-template-columns: 30vw;
grid-template-rows: repeat(3,10vh) 5vh repeat(2,10vh);
grid-gap: 10px;

}
body{
background: black;
}

h1{
text-align: center;
color: white;
}
.submit-btn{
background-color: turquoise;
}
.bmi-value{
background-color: yellow;
display: grid;
grid-template-rows: 50% 50%;
}
.status{
background-color: aquamarine;
display: grid;
grid-template-rows: 50% 50%;

}
.container > div{
padding: 10px;
font-size: 20px;
font-weight: bold;
color: black;
border-radius: 10px;
}
button,input{
min-width: 100%;
min-height: 100%;
border: none;
outline: none;
font-size: 1.5vw;
border-radius: 8px;
}
input{
background: #ffdd99;
text-indent: 0.5em;
max-width:100% ;
color: black;
outline: none;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
input[type=number] {
-moz-appearance: textfield;
}
button{
background: tomato;
cursor: pointer;
}
button:hover{
background: #c70039;
color: white;
}