Question
Language is Java. Calculate the Body Mass Index (BMI) given a weight in pounds and a height in inches. The BMI is defined as the
Language is Java.
Calculate the Body Mass Index (BMI) given a weight in pounds and a height in inches.
The BMI is defined as the body weight in kilograms divided by the square of the height in meters.
Convert pounds to kilograms by dividing pounds by 2.2;
Convert inches to meters by multiplying by 0.0254.
Use the Scanner class to get the user input from the keyboard, and display as output the weight in kilograms, the height in meters, and the BMI in kg/m2.
Use the static method Math.pow( ) to find the square of the height.
Use the following template:
import java.util.*;
public class BMI {
// pounds to kilograms
final static double CONVWGT = 2.2
// inches to meters
final static double CONVHGT = 0.0254;
public static void main (String [] args) {
double bmi;
Scanner input = new Scanner(System.in);
// put the problem solution here
System.out.printf( BMI: %.2f , bmi);
return;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started