I found the answer,
but thanks for all the
help!
For my c++ class I have to make a small win32 console program that
calculates body mass index. The user will enter in a their first and
last initial then their height, then weight. After calculating the
bmi the program tells the person if they are fat or not. I need to
loop this portion of the program until the user enters in an * for
the first initial, and if they enter it in on the first time the
program must end. I am stuck any suggestions? Below is what I have so
far.
#include <iostream>
using namespace std;
void main()
{
// declare variables
char FirstInitial = 0, SecondInitial = 0;
int height, weight;
double inTo_m, lbTo_kg, meters_squared, bmi;
cout << "Programed By jfufjsi jisoslent" <<
endl << endl;
cout << "Type an (*) for the first initial to
exit." << endl;
// input
cout << "Enter your first and last initial: ";
cin >> FirstInitial;
cin >> SecondInitial;
cout << "Enter your height in inches: ";
cin >> height;
cout << "Enter your weight in pounds: ";
cin >> weight;
cout << endl << endl;
// convert height in inches to meters squared
inTo_m = (height * 2.54) / 100;
meters_squared = inTo_m * inTo_m;
// convert weight in pounds to kilograms
lbTo_kg = (weight * 16) * .0283495231;
// find BMI
bmi = lbTo_kg / meters_squared;
// sets the places after the decimal and display initials and bmi
cout.precision(2);
cout.setf(ios::fixed);
cout << FirstInitial << ". " <<
SecondInitial << ". "
<< "your BMI is : "
<< bmi << endl << endl;
// if/else if loop to test for bmi weight match
if (bmi < 18.5)
{
cout << " You are underweight" << endl
<< endl << endl;
}
else if (bmi >= 18.5 && bmi < 25)
{
cout << " You are a normal weight" <<
endl << endl << endl;
}
else if (bmi >= 25 && bmi < 30)
{
cout << " You are overweight" << endl
<< endl << endl;
}
else if (bmi >= 30)
{
cout << " You are obese" << endl
<< endl << endl;
}
}
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com