#C13000. BMI Calculator

    ID: 42491 Type: Default 1000ms 256MiB

BMI Calculator

BMI Calculator

Given a person's weight (in kilograms) and height (in meters), compute their Body Mass Index (BMI) using the formula: \(\text{BMI} = \frac{\text{weight}}{\text{height}^2}\). Round the result to one decimal place and then classify the BMI into one of the following categories:

  • Underweight if \(\text{BMI} < 18.5\)
  • Normal weight if \(18.5 \leq \text{BMI} < 24.9\)
  • Overweight if \(25.0 \leq \text{BMI} < 29.9\)
  • Obesity if \(\text{BMI} \geq 29.9\)

Note that if the height is less than or equal to zero, you should output "Height must be greater than zero." and if the weight is negative, output "Weight must be non-negative.". The classification is based on the BMI value rounded to one decimal place.

inputFormat

The input consists of two floating point numbers: weight (in kilograms) and height (in meters). These numbers are provided via standard input, separated by whitespace (spaces or newlines).

outputFormat

If the input values are valid, output the BMI (rounded to one decimal place), followed by a comma, a space, and then the corresponding BMI category. If an exceptional case arises (such as a non-positive height or a negative weight), output the appropriate error message.

## sample
70 1.75
22.9, Normal weight