Now that we know how to get input from the user and store it into variables
and since we know how to do some basic math, we can now write our first
What You Should See
This exercise is (hopefully) pretty straightforward. We have three variables
(all doubles): m (meters), kg (kilograms) and bmi (body mass index).
We read in values for m and kg, but bmi’s value comes not from the
human but as the result of a calculation. On line 14 we compute the mass
divided by the square of the height and store the result into bmi.
And then we print it out.
The body mass index (BMI) is commonly used by health and nutrition
professionals to estimate human body fat in populations. So this result
would be informative for a health professional. For now that’s all
we can do with it.
Eventually we will learn how to display a different message on the screen
depending on what value is in the BMI variable, but for now this will
have to do.
Today’s exercise is hopefully pretty easy to understand, but the Study
Drills are quite a bit tougher than usual this time. If you can get them
done without help, then your understanding is probably pretty good.