// Alicia Thorsen // bmi.C // 1/18/08 // // Calculates a person's Body Mass Index (BMI) using his/her weight and height. // Outputs the corresponding weight category for the given BMI. #include using namespace std; int main() { double weight = 0, height = 0, bmi = 0; int heightFt = 0, heightIn = 0; char temp; // Get user's weight and height cout << "\nEnter weight in lbs: "; cin >> weight; cout << "Enter height (e.g. 5'7\"): "; cin >> heightFt >> temp >> heightIn >> temp; // Convert to metric units weight /= 2.2; height = ((heightFt * 12) + heightIn) * 0.0254; // Calculate and output BMI bmi = weight / (height * height); cout.setf(ios::fixed | ios::showpoint); cout.precision(1); cout << "\nYour BMI is " << bmi << ".\n"; // Output BMI category cout << "Based on your BMI, "; if (bmi < 18.5) cout << "you are underweight."; else if (bmi < 25) cout << "your weight is normal."; else if (bmi < 30) cout << "you are overweight."; else cout << "you are obese."; cout << endl << endl; return 0; }