Calculators

Calories Calculator

Calories Calculator

Underweight Healthy Overweight Obese
Enter your weight
Body Mass Index (BMI) is a measure of body fat based on height and weight.

Your BMI Result:

0

Understanding Calories & Nutrition

Calories are units of energy that our bodies use to function. The number of calories you need depends on several factors including your age, gender, weight, height, and activity level.

BMI (Body Mass Index): A value derived from height and weight that categorizes you as underweight, normal weight, overweight, or obese.

BMR (Basal Metabolic Rate): The number of calories your body needs to perform basic life-sustaining functions.

Daily Calorie Needs: The total number of calories you need per day based on your BMR and activity level.

Use this calculator to determine your BMI, BMR, and daily calorie requirements to help you maintain a healthy lifestyle!

`); setHTML(iconBox, ''); infoBox.textContent = 'Body Mass Index (BMI) is a measure of body fat based on height and weight.'; resultTitle.textContent = 'Your BMI Result:'; } function viewBMR() { setHTML(inputsBox, `
`); setHTML(iconBox, ''); infoBox.textContent = 'Basal Metabolic Rate (BMR) is the number of calories your body needs at rest.'; resultTitle.textContent = 'Your BMR Result:'; } function viewCalories() { setHTML(inputsBox, `
`); setHTML(iconBox, ''); infoBox.textContent = 'Daily calorie needs are based on your BMR multiplied by your activity level.'; resultTitle.textContent = 'Your Daily Calories:'; } function viewFood() { setHTML(inputsBox, `
`); setHTML(iconBox, ''); infoBox.textContent = 'Calorie content varies by food type and quantity.'; resultTitle.textContent = 'Food Calories:'; } function changeType() { const t = typeSelect.value; if (t === 'bmi') viewBMI(); else if (t === 'bmr') viewBMR(); else if (t === 'calories') viewCalories(); else viewFood(); // hide result on change resultBox.style.display = 'none'; // reset meter status updateMeter(); } function updateMeter() { const wEl = $('#ct-weight'); const hEl = $('#ct-height'); if (wEl && hEl && wEl.value && hEl.value) { const weight = parseFloat(wEl.value); const height = parseFloat(hEl.value) / 100; if (weight > 0 && height > 0) { const bmi = weight / (height * height); let pos, txt, col; if (bmi < 18.5) { pos = (bmi / 18.5) * 25; txt = 'Underweight'; col = '#FF9800'; } else if (bmi < 25) { pos = 25 + ((bmi - 18.5) / (25 - 18.5)) * 35; txt = 'Healthy Weight'; col = '#4CAF50'; } else if (bmi < 30) { pos = 60 + ((bmi - 25) / (30 - 25)) * 20; txt = 'Overweight'; col = '#FFEB3B'; } else { pos = 80 + (Math.min(bmi, 40) - 30) / (40 - 30) * 20; txt = 'Obese'; col = '#F44336'; } pos = Math.max(0, Math.min(100, pos)); const oscillation = Math.sin(Date.now() / 500) * 0.5; needle.style.left = `calc(${pos}% + ${oscillation}px)`; status.textContent = `${txt} (BMI: ${bmi.toFixed(1)})`; status.style.color = col; return; } } needle.style.left = '0%'; status.textContent = 'Enter your weight and height'; status.style.color = '#555'; } function calc() { const t = typeSelect.value; let result = 0; try { if (t === 'bmi') { const w = parseFloat($('#ct-weight').value); const h = parseFloat($('#ct-height').value) / 100; if (!(w > 0 && h > 0)) throw new Error('Please enter valid weight and height'); result = w / (h * h); resultValue.innerHTML = result.toFixed(1) + ' BMI'; } else if (t === 'bmr') { const age = parseInt($('#ct-age').value); const gender = $('#ct-gender').value; const w = parseFloat($('#ct-weight').value); const h = parseFloat($('#ct-height').value); if (!(age > 0 && w > 0 && h > 0)) throw new Error('Please enter valid values for all fields'); result = gender === 'male' ? 10 * w + 6.25 * h - 5 * age + 5 : 10 * w + 6.25 * h - 5 * age - 161; resultValue.innerHTML = Math.round(result) + ' calories/day'; } else if (t === 'calories') { const age = parseInt($('#ct-age').value); const gender = $('#ct-gender').value; const w = parseFloat($('#ct-weight').value); const h = parseFloat($('#ct-height').value); const act = parseFloat($('#ct-activity').value); if (!(age > 0 && w > 0 && h > 0)) throw new Error('Please enter valid values for all fields'); const bmr = gender === 'male' ? 10 * w + 6.25 * h - 5 * age + 5 : 10 * w + 6.25 * h - 5 * age - 161; result = bmr * act; resultValue.innerHTML = Math.round(result) + ' calories/day'; } else { const item = $('#ct-food').value; const qty = parseInt($('#ct-qty').value); if (!(qty > 0)) throw new Error('Please enter a valid quantity'); const kcal = { apple: 95, banana: 105, chickenBreast: 165, pasta: 131, pizza: 285, salad: 15 }; result = (kcal[item] || 0) * qty; resultValue.innerHTML = Math.round(result) + ' calories'; } resultBox.style.display = 'block'; } catch (e) { alert(e.message); } } // Events typeSelect.addEventListener('change', changeType); root.addEventListener('input', (e) => { if (e.target && (e.target.id === 'ct-weight' || e.target.id === 'ct-height')) updateMeter(); }); calcBtn.addEventListener('click', calc); // Init changeType(); setInterval(updateMeter, 100); })();
zaheerpashamd

Share
Published by
zaheerpashamd

Recent Posts

Protect PDF

Protect PDF - Add Password | Secure & Free Protect PDF Add password protection to…

2 months ago

PNG to PDF Converter

PNG to PDF Converter PNG to PDF Converter Upload your PNG images and convert them…

2 months ago

PDF to PNG Converter

PDF to PNG Converter PDF to PNG Converter Upload your PDF file and convert it…

2 months ago

Advanced Image Resize Tool

Advanced Image Resize Tool - Free Online Image Resizer Home > Tools > Image Resize…

3 months ago

Geometry Calculator

Geometry Calculator Geometry Calculator Calculate area, perimeter, volume, and other properties of geometric shapes Select…

3 months ago

Algebra Calculator

Algebra Calculator Algebra Calculator Solve equations, simplify expressions, and perform algebraic operations Enter Expression or…

3 months ago