In: Computer Science
In Java, need to create a program with Body Mass Index (BMI) is a measure of health on weight. It can be calculated by taking your weight in kilograms and dividing, by the square of your height in meters. Write a program that prompts the user to enter a weight in pounds and height in inches and displays the BMI. Note one pound is 0.45359237 kilograms and one inch is 0.0254 meters.
Here is a sample run:
Enter weight in pounds: 95.5 ⏎
Enter your height in inches: 4.25 ⏎
BMI is 26.8573
Also need a flowchart
Flowchart:
Java program:
// Java program to calculate Body Mass Index (BMI) given its height and weight
public class BMI{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
double weight, height;
// input of weight
System.out.print("Enter weight in pounds: ");
weight = scan.nextDouble();
// input of height
System.out.print("Enter your height in inches: ");
height = scan.nextDouble();
// calculate bmi by converting weight to kg and height to m
double bmi = (weight*0.45359237)/(Math.pow(height*0.0254,2));
// print bmi
System.out.println("BMI is "+bmi);
scan.close();
}
}
//end of program
Output: