Skip to content

Commit

Permalink
Merge pull request #1876 from Saipradyumnagoud/master
Browse files Browse the repository at this point in the history
Added Blood Pressure Caluclator
  • Loading branch information
Sulagna-Dutta-Roy authored Jun 23, 2024
2 parents db1541d + 49c77e9 commit b238d83
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Blood Pressure Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BP Calculator</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<h1>Blood Pressure Calculator</h1>
<form id="bp-form">
<label for="systolic">Systolic (mmHg):</label>
<input type="number" id="systolic" name="systolic" required>

<label for="diastolic">Diastolic (mmHg):</label>
<input type="number" id="diastolic" name="diastolic" required>

<button type="button" onclick="calculateBP()">Calculate</button>
</form>
<div id="result"></div>
</div>
<script src="script.js"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions Blood Pressure Calculator/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "Blood Pressure Calculator",
"short_name": "BP Calculator",
"description": "A simple Blood Pressure Calculator.",
"start_url": "./index.html",
"display": "standalone",
"background_color": "#f2f2f2",
"theme_color": "#007bff",
"icons": [
{
"src": "icons/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "icons/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}

25 changes: 25 additions & 0 deletions Blood Pressure Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
function calculateBP() {
const systolic = parseInt(document.getElementById('systolic').value);
const diastolic = parseInt(document.getElementById('diastolic').value);
let resultText = '';

if (systolic && diastolic) {
if (systolic < 120 && diastolic < 80) {
resultText = 'Normal Blood Pressure';
} else if (systolic < 130 && diastolic < 80) {
resultText = 'Elevated Blood Pressure';
} else if (systolic < 140 || diastolic < 90) {
resultText = 'Hypertension Stage 1';
} else if (systolic >= 140 || diastolic >= 90) {
resultText = 'Hypertension Stage 2';
} else if (systolic > 180 || diastolic > 120) {
resultText = 'Hypertensive Crisis (Consult your doctor immediately)';
} else {
resultText = 'Invalid Input';
}
} else {
resultText = 'Please enter both systolic and diastolic values.';
}

document.getElementById('result').innerText = resultText;
}
59 changes: 59 additions & 0 deletions Blood Pressure Calculator/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
body {
font-family: Arial, sans-serif;
background-color: #f4f4f9;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}

.container {
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
}

h1 {
margin-bottom: 20px;
}

form {
display: flex;
flex-direction: column;
align-items: center;
}

label {
margin: 10px 0 5px;
}

input {
padding: 10px;
margin-bottom: 20px;
width: 200px;
border: 1px solid #ccc;
border-radius: 4px;
}

button {
padding: 10px 20px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
}

button:hover {
background-color: #0056b3;
}

#result {
margin-top: 20px;
font-size: 1.2em;
color: #333;
}

0 comments on commit b238d83

Please sign in to comment.