00:01
In this video, we will create a program that calculates bmi by revising the listing 3 .4, compute, and interpret bmi .java.
00:10
To let the user enter weight, feet, and inches, for example, if a person is 5 feet 10 inches, they will enter 5 for feet and then space 10 for inches.
00:24
I've already defined our class as well as the main method within it.
00:27
I've also imported java .util .scanner since we know we'll be taking user input.
00:35
So the first thing we can go ahead and do is go into our main method and create a new scanner object named input by calling scanner with the argument system .in, which allows keyboard input to be read from inside of our java application.
00:59
The next thing we want to do is use system .0.
01:04
Println, since we'll be prompting the user to enter their weight in pounds, so we can say enter weight in pounds.
01:30
After this, we'll want to prompt the user to enter their height in inches.
01:37
As stated by prompt for this question, i'm just.
01:47
Just going to copy and paste this statement to the user, prompting them to first enter the height in terms of feet followed by a space and then inches.
02:16
Now after this, we're going to want to store both the feet and the inches separately, so we can do double feet equals and input.
02:34
Next double.
02:37
And then after this, since there's a space, after the input of feet, we'll do double inches equals input.
02:47
The next double as well.
02:52
After this, we'll get our height.
02:55
So we can calculate the height and declare variable.
03:01
So we're going to do inches plus feet times 12.
03:07
So we're converting our feet to inches and then adding the inches.
03:17
So at this point we have our height.
03:20
The next thing we're going to want to do is declare two constant variables because your constant we're going to use final before double.
03:40
And our constant is going to be kilograms per pound.
03:46
Capitalization with underscores is the appropriate way to name our constant.
04:00
This is just what we do to let a user reading our program know immediately.
04:14
Oh, this is a constant.
04:16
So it's more recognizable with the capital.
04:26
Next, we have meters per inch, 0 .0.
04:32
To 5 -4.
04:34
So now we have both of our constants because when we compute bmi, we're going to want to get our weight in kilograms, as well as our height in meters...