In this activity, we are going to implement the previousalgorithm in Java. Just in case, here is problem again: Thisprogram calculates and displays a person's body mass index (BMI).The BMI is calculated as the weight times 703 divided by the heightsquared where the weight is measured in pounds and the height ininches. The program should display a message indicating whether theperson has optimal weight (BMI between 18.5 and 25), is underweight(BMI is less than 18.5), or overweight (BMI is greater than25).
Important considerations:
1. There are several ways to design and implement thisalgorithm; however, for the purpose of this exercise and for anautomatic grading, we are going to use the algorithm developed inthe previous exercise.
2. Because of the softchalk limitation about the uses of doublequotation marks, and for uniformity, the String objects have beencreated for you.
3. For the calculation, you must use the Math library for theexponentiation.
4. The curly braces for the if-else statement blocks are locatedin separate lines for uniformity.
Given the following skeleton, please add the missinginstructions
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
double weight;
double height;
double bmi;
String stWeight = \"Enter your weight (pounds) \";
String stHeight = \"Enter your height (inches) \";
String stBMI = \"Your BMI is \";
String stOver = \"You are considered Overweight\";
String stOptimal = \"You have optimal weight\";
String stUnder = \"You are considered Underweight\";
Fill in: ALL OF THE BLANKS HAVE TO BE FILLEDIN!!
//Input prompt the user for weight and height in that order
System.out.println(stWeight); |
|
System.out.println(stHeight); |
|
//Calculate BMI
// Display results of calculation and the message in differentlines
//Overweight
//Optimal Weight
//Underweight
}