#C246. BMI Calculator
BMI Calculator
BMI Calculator
This problem requires you to compute the Body Mass Index (BMI) of an individual given their weight in kilograms and height in meters. The BMI is defined by the formula: $$\text{BMI} = \frac{\text{weight}}{\text{height}^2}$$. You must ensure that both weight and height are positive values. If either value is non-positive, the program should output an appropriate error message.
Input will be provided via standard input (stdin) as two space-separated numbers. Your program should output the computed BMI or an error message via standard output (stdout).
inputFormat
The input consists of a single line containing two space-separated numbers:
- weight: A positive floating-point number representing the weight in kilograms.
- height: A positive floating-point number representing the height in meters.
outputFormat
If both inputs are positive, output the BMI value calculated as $$\text{BMI} = \frac{\text{weight}}{\text{height}^2}$$. If either of the inputs is non-positive, output the error message:
- If weight is not positive:
Weight must be a positive value.
- If height is not positive:
Height must be a positive value.
70 1.75
22.857142857142858