/*
Chapter 3:
Chapter Walk Through part2 (The Body Mass Index Calculator)
Programmer: Brad Shedd
Date:
April 17, 2006
Filename:
BodyMassSwing.java
Purpose: This project
calculates the body mass index based
on a person's height and weight.
*/
import javax.swing.JOptionPane;
public
class
BodyMassSwing
{
public
static
void
main(String[] args)
{
// delare an
construct variables
String height, weight;
int
inches, pounds;
double
kilograms, meters, index;
// print
prompts and get input
System.out.println("\tTHE
SUN FITNESS CENTER BODY MASS INDEX CALCULATOR");
index = 1;
while
(index != 0)
{
height=JOptionPane.showInputDialog(null,"Enter
your height to the nearest inch: ");
inches = Integer.parseInt(height);
weight=JOptionPane.showInputDialog(null,"Enter
your weight to the nearest pound: ");
pounds = Integer.parseInt(weight);
//
calculations
meters = inches / 39.36;
kilograms
= pounds / 2.2;
index = kilograms / Math.pow(meters,2);
//
output
JOptionPane.showMessageDialog(null,
"YOUR BODY MASS INDEX IS "
+ Math.round(index) +".",
"Body
Mass Calculator",JOptionPane.PLAIN_MESSAGE );
}
System.exit(0);
}
// end of
main method
}
// end of BodyMassSwing class