Answer:
You need to find out what is the units of measurement of the height and weight. You also need to find that the weight is in Kilogram or pounds, and whether the height is in feet and inches, or inches, or meters and centimeters.
Part1: You need to read the values of the weight and height, and validate it as required.
Part2: Now you need to convert those findings into English measures or metrics for computation.
Part3: Output: You need to display as well as echo the input as well as the BMI; and you need to mention the supplementary message which is based on the BMI findings related to Obesity, borderline overweight, normal and overweight, etc.
The program is as below:
import java.io. *;
class Main
{
// weight in pounds and heights are in inches
private double your_wght;
private double your_hght;
Main ( double ht, double wt)
{
your_wght = wt; your_hght = ht;
}
public double GetHght() { return(your_hght); }
public double GetWght() { return(your_wght); }
public double CalculBMI() { return(your_wght*703/(your_hght*your_hght)); }
public double PrintDouble( String promptMessage) throws IOException
{
double Num=0;
String x=null;
Console console = System.console();
System.out.print(promptMessage);
x = console.readLine();
Num = Double.parseDouble(x);
return(Num);
}
public static void main( String args[])
{
double heightinFeet=0,heightinInch=0,w=0;
Main Input = new Main(0,0);
try
{
System.out.println(" Please input the height(feet/inches) \\");
heightinFeet = Input.PrintDouble(" In feet :> ");
heightinInch = Input.PrintDouble(" In inches :> ");
w = Input.PrintDouble(" Please enter the weight(pounds) :>");
}
catch (IOException ex) { System.out.println("occurred Input Exception"); }
Main BMI_value = new Main(heightinFeet*12+heightinInch,w);
System.out.println(" Weight = " + BMI_value.GetWght() );
System.out.println(" Height(inches) " + BMI_value.GetHght() );
System.out.println(" BMI is " + BMI_value.CalculBMI() );
}
}
Step-by-step explanation:
Rest of the fields and properties are self understood, however, PrintMessage needs explanation. It takes a string as input, which calls for entering some double value like in feet, and in inches, and returns that value, which is assigned to relevant double variable. And Main is the class with Main constructor, which is a parameterized constructor, and takes height and weight as input.