BMI Calculator - Problem
Calculate the Body Mass Index (BMI) from a person's height and weight, then determine which category they fall into.
BMI Formula: BMI = weight (kg) / (height (m))²
Categories:
- Underweight: BMI < 18.5
- Normal weight: BMI 18.5 - 24.9
- Overweight: BMI 25.0 - 29.9
- Obese: BMI ≥ 30.0
Return the BMI value rounded to 1 decimal place and the corresponding category as a string.
Input & Output
Example 1 — Normal Weight
$
Input:
weight = 70, height = 1.75
›
Output:
22.9 Normal weight
💡 Note:
BMI = 70 / (1.75)² = 70 / 3.0625 = 22.857... rounds to 22.9. Since 18.5 ≤ 22.9 < 25.0, category is Normal weight.
Example 2 — Overweight
$
Input:
weight = 85, height = 1.70
›
Output:
29.4 Overweight
💡 Note:
BMI = 85 / (1.70)² = 85 / 2.89 = 29.411... rounds to 29.4. Since 25.0 ≤ 29.4 < 30.0, category is Overweight.
Example 3 — Underweight
$
Input:
weight = 45, height = 1.65
›
Output:
16.5 Underweight
💡 Note:
BMI = 45 / (1.65)² = 45 / 2.7225 = 16.528... rounds to 16.5. Since 16.5 < 18.5, category is Underweight.
Constraints
- 1 ≤ weight ≤ 1000
- 0.1 ≤ height ≤ 3.0
- BMI will be rounded to 1 decimal place
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code