
Andy C. answered 07/25/17
Tutor
4.9
(27)
Math/Physics Tutor
import javax.swing.*;
class BMI
{
private double height;
private double weight;
private double bmi;
BMI()
{
weight = height = 0;
}
private void Input()
{
String inbuff="?";
inbuff = JOptionPane.showInputDialog(" Please input the height in inches ");
height = Double.parseDouble(inbuff);
inbuff = JOptionPane.showInputDialog(" Please input the weight in pounds ");
weight = Double.parseDouble(inbuff);
}
public void calculateBMI()
{
bmi = weight * 703/(height*height);
}
public void outputBMI()
{
JOptionPane.showMessageDialog(null," The BMI is " + bmi);
}
public static void main(String args[])
{
BMI myBMI = new BMI();
myBMI.Input();
myBMI.calculateBMI();
myBMI.outputBMI();
}
} //class BMI
class BMI
{
private double height;
private double weight;
private double bmi;
BMI()
{
weight = height = 0;
}
private void Input()
{
String inbuff="?";
inbuff = JOptionPane.showInputDialog(" Please input the height in inches ");
height = Double.parseDouble(inbuff);
inbuff = JOptionPane.showInputDialog(" Please input the weight in pounds ");
weight = Double.parseDouble(inbuff);
}
public void calculateBMI()
{
bmi = weight * 703/(height*height);
}
public void outputBMI()
{
JOptionPane.showMessageDialog(null," The BMI is " + bmi);
}
public static void main(String args[])
{
BMI myBMI = new BMI();
myBMI.Input();
myBMI.calculateBMI();
myBMI.outputBMI();
}
} //class BMI