Tracking your BMI is a useful way of checking if you’re maintaining a healthy weight. It’s calculated using a person’s weight and height, using this formula: weight / height²
The resulting number indicates one of the following categories:
Underweight = less than 18.5
Normal = more or equal to 18.5 and less than 25
Overweight = more or equal to 25 and less than 30
Obesity = 30 or more
Let’s make finding out your BMI quicker and easier, by creating a program that takes a person’s weight and height as input and outputs the corresponding BMI category.
Line 1: Assigns a data type Integer to weight and let the computer know that the input from user will be of Integer type.
Line 2: The same as line 1 however the data type is of float because there are certain decimal values that can be placed. Line 1 could also be Float if you want to be more specific of your weight.
Line 3: X will be the variable storage of the formula “weight/float(height*height);“
Line 4 and 5: Determines if the output is below 18.5 then the user is Underweight. Further, the same will be displayed relative to the formulas in each condition