Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calorie calculator #247

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
27 changes: 27 additions & 0 deletions Calculators/Calorie_Calculator/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
document.getElementById("mbutton").addEventListener("click", () => {
mAge = document.getElementById("mAge")
mWeight = document.getElementById("mWeight")
mHeight = document.getElementById("mHeight")
if (validate(mAge.value) || validate(mWeight.value) || validate(mHeight.value))
return;
answer = 0 - 5 * +mAge.value + 10 * +mWeight.value + 6.25 * +mHeight.value
if (document.getElementById('mMale').checked)
answer += 5
else
answer -= 161
document.getElementById("mResult").innerHTML = "Your Basic Metabolic Rate = " + answer + " Calories"
});
// document.getElementById("ubutton").addEventListener("click", () => {
// uAge = document.getElementById("uAge")
// uWeight = document.getElementById("uWeight")
// uHeight = document.getElementById("uHeight")
// answer = 0 - 5 * +mAge.value + 10 * +mWeight.value + 6.25 * +mHeight.value
// if (document.getElementById('mMale').checked)
// answer += 5
// else
// answer -= 161
// document.getElementById("uResult").innerHTML = "Your Basic Metabolic Rate =" + answer + " Calories"
// });
function validate(value) {
return value==="";
}
72 changes: 72 additions & 0 deletions Calculators/Calorie_Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!DOCTYPE HTML>
<html>

<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<link rel="stylesheet" href="./style.css">
<title>Calorie Calculator</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>

<body class="bg-dark text-white">
<div class="container">
<div class="mt-5 offset-sm-2 col-sm-8 box">
<h1 class="text-center ">Based on Mifflin-St Jeor Equation</h1>
<!-- Nav tabs -->
<ul class="nav nav-tabs ps-2 pe-2">
<li class="nav-item">
<a class="nav-link active " data-bs-toggle="tab" href="#Metric">Metric Units</a>
</li>

</ul>

<!-- Tab panes -->
<div class="tab-content p-2">
<div class="tab-pane container active container-form " id="Metric">
<form class="row g-3 box-form tab-pane active" id="">
<div class="col-6">
<label for="mAge" class="form-label">Age</label>
<input type="number" class="form-control" id="mAge">
</div>
<div class="col-12">
<label for="Age" class="form-label">Gender</label><br>
<div class="btn-group" role="group" aria-label="Basic radio toggle button group"
id="mGender">
<input type="radio" class="btn-check" name="btnradio" id="mMale" autocomplete="off"
checked>
<label class="btn btn-outline-warning" for="mMale">Male</label>

<input type="radio" class="btn-check" name="btnradio" id="mFemale" autocomplete="off">
<label class="btn btn-outline-warning" for="mFemale">Female</label>
</div>
</div>
<div class="col-6">
<label for="mHeight" class="form-label">Height</label>
<input type="number" class="form-control" id="mHeight" placeholder="in cm">
</div>
<div class="col-6">
<label for="mWeight" class="form-label">Weight</label>
<input type="number" class="form-control" id="mWeight" placeholder="in kg">
</div>

<div class="col-12">
<button type="button" class="btn btn-success" id="mbutton">Calculate</button>
</div>
<div class="col-12 text-center">
<h1 id="mResult"></h1>
</div>
</form>
</div>

</div>
</div>
</div>
</body>
<script src="./app.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous"></script>

</html>
Empty file.
8 changes: 8 additions & 0 deletions Calculators/Calorie_Calculator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.box{
background-color: rgb(114, 45, 233);
border: 2px solid rgb(114, 45, 233);
border-radius: 5px;
}
a{
color: red !important;
}