Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
Terms of Agreement:
By using this code, you agree to the following terms...
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame.
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
//
/* Body Mass Index.cpp
this program will take in a person's height in inches and weight
in pounds and returns the body mass index (BMI). BMI is defined
as the weight, expressed in kilograms, divided by the square of
the height expressed in meters.
Program by: David Turner
September 25, 1999
*/
#include
//Function prototype:
double BodyMassIndex(int inches, int lbs);
/******************************************************************/
/******************** Main*********************/
/******************************************************************/
int main()
{
int inches, lbs;
double BMIndex;
//User enters in input:
cout << "BODY MASS INDEX\n";
cout << endl;
cout << endl;
cout << "To quit this program enter in a zero for your height "
<< "and weight\n";
cout << endl;
cout << "Please enter your height in inches : ";
cin >> inches;
cout << endl;
cout << "Please enter your weight in pounds : ";
cin >> lbs;
while ((inches != 0) && (lbs != 0))
{
BMIndex = BodyMassIndex(inches, lbs);
cout << "Your BMI is " << BMIndex << endl;
cout << endl;
cout << "Please enter your height in inches : ";
cin >> inches;
cout << endl;
cout << "Please enter your weight in pounds : ";
cin >> lbs;
}
cout << endl;
cout << endl;
return 0;
}
/*******************************************************************/
/*******************Body Mass Index ********************/
/*******************************************************************/
double BodyMassIndex(int inches, int lbs)
{
double BMI, weight, height;
weight = lbs * 0.454;
height = inches * 0.0254;
BMI = weight / (height * height);
return BMI;
}