This calculator estimates the number of calories you burn during an exercise session based on your heart rate, duration, and personal factors. It's important to note that this is an estimation, and actual calorie burn can vary significantly due to individual metabolism, fitness level, and exercise intensity.
Male
Female
.calculator-container {
font-family: Arial, sans-serif;
max-width: 600px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ddd;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.calculator-inputs {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 15px;
margin-bottom: 20px;
}
.input-group {
display: flex;
flex-direction: column;
}
.input-group label {
margin-bottom: 5px;
font-weight: bold;
color: #333;
}
.input-group input, .input-group select {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1rem;
}
button {
background-color: #4CAF50;
color: white;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1.1rem;
transition: background-color 0.3s ease;
width: 100%;
margin-top: 15px;
}
button:hover {
background-color: #45a049;
}
.calculator-result {
margin-top: 25px;
padding: 15px;
background-color: #e9f5e9;
border-left: 4px solid #4CAF50;
font-size: 1.2rem;
font-weight: bold;
color: #333;
text-align: center;
}
function calculateCalories() {
var age = parseFloat(document.getElementById("age").value);
var weightKg = parseFloat(document.getElementById("weightKg").value);
var heartRate = parseFloat(document.getElementById("heartRate").value);
var durationMinutes = parseFloat(document.getElementById("durationMinutes").value);
var gender = document.getElementById("gender").value;
var resultElement = document.getElementById("result");
resultElement.innerHTML = ""; // Clear previous results
// Validate inputs
if (isNaN(age) || isNaN(weightKg) || isNaN(heartRate) || isNaN(durationMinutes) || age <= 0 || weightKg <= 0 || heartRate <= 0 || durationMinutes 160) {
metValue = 15; // Very high intensity
} else if (heartRate > 140) {
metValue = 10; // High intensity
} else if (heartRate > 120) {
metValue = 7; // Moderate intensity
} else if (heartRate > 100) {
metValue = 5; // Low to moderate intensity
} else {
metValue = 3; // Very low intensity
}
// Standard calorie burn formula: Calories = MET * weight (kg) * duration (hours)
// Adjusting slightly for gender differences which are often incorporated into more precise formulas,
// but for a simple model, the MET value itself is the primary driver.
// A common modification for heart rate-based estimation for exercise:
// Calories per minute = (MET * 3.5 * weightKg) / 200
var caloriesPerMinute = (metValue * 3.5 * weightKg) / 200;
var totalCaloriesBurned = caloriesPerMinute * durationMinutes;
// Basic gender adjustment can be applied, though MET is more dominant.
// For simplicity, we'll primarily rely on the MET derived from heart rate.
// More complex formulas would use age, weight, height, VO2max etc.
resultElement.innerHTML = "Estimated Calories Burned: " + totalCaloriesBurned.toFixed(2) + " kcal";
}