//Devin Scheu CS1A Chapter 4, P. 220, #5
//
/**************************************************************
*
* CALCULATE BODY MASS INDEX (BMI)
* ____________________________________________________________
* This program calculates a person's body mass index (BMI)
* based on weight (in pounds) and height (in inches). It then
* determines if the person is underweight, optimal weight, or
* overweight.
*
* Computation is based on the formula:
* BMI = weight * 703 / (height * height)
* Optimal BMI range: 18.5 to 25
* ____________________________________________________________
* INPUT
* weight : Weight in pounds (as a double)
* height : Height in inches (as a double)
*
* OUTPUT
* message : Indicates whether the person is underweight, optimal, or overweight
*
**************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main () {
//Variable Declarations
double weight; //INPUT - Weight in pounds (as a double)
double height; //INPUT - Height in inches (as a double)
double bmi; //PROCESSING - Body mass index calculated from weight and height
string message; //OUTPUT - Indicates whether the person is underweight, optimal, or overweight
//Prompt for Input
cout << "Enter your weight in pounds: ";
cin >> weight;
cout << "\nEnter your height in inches: ";
cin >> height;
//Calculate BMI
bmi = weight * 703 / (height * height);
//Determine Weight Status
if (bmi < 18.5) {
message = "You are underweight.";
} else if (bmi >= 18.5 && bmi <= 25) {
message = "You have optimal weight.";
} else {
message = "You are overweight.";
}
//Output Result
cout << fixed << setprecision(2);
cout << "\n";
cout << left << setw(25) << "Weight:" << right << setw(15) << weight << " lbs" << endl;
cout << left << setw(25) << "Height:" << right << setw(15) << height << " in" << endl;
cout << left << setw(25) << "BMI:" << right << setw(15) << bmi << endl;
cout << left << setw(25) << "Status:" << right << setw(15) << message << endl;
} //end of main()