/*
Chapter 3:
Chapter Walk Through(The Body Mass Index Calculator)
Programmer: Brad Shedd
Date:
April 17, 2006
Filename:
BodyMass.java
Purpose:
This project calculates the body mass index based
on a person's height and weight.
*/
import java.io.*;
// loads in io package to allow for data entry
public
class
BodyMass
{
public
static
void
main(String[] args)
throws
IOException
// warns compiler of input output errors
{
// delare
and construct variables
String height, weight;
int
inches, pounds;
double
kilograms, meters, index;
BufferedReader dataIn=
new
BufferedReader(new
InputStreamReader(System.in));
index = 0;
while
(index != 1)
{
// print
prompts and get input
System.out.println("\tTHE
SUN FITNESS CENTER BODY MASS INDEX CALCULATOR");
System.out.println();
System.out.print("\t\tEnter
your height to the nearest inch: ");
height = dataIn.readLine();
inches = Integer.parseInt(height);
System.out.print("\t\tEnter
your weight to the nearest pound: ");
weight = dataIn.readLine();
pounds = Integer.parseInt(weight);
//
calculations
meters = inches / 39.36;
kilograms = pounds / 2.2;
index = kilograms
/ Math.pow(meters,2);
//
output
System.out.println();
System.out.println("\tYOUR
BODY MASS INDEX IS " + Math.round(index) +".");
System.out.println();
}
}
// end of
main method
}
// end of BodyMass class