I was asked to make this program to calculate a persons Body Mass Index. US_IMPERIAL
is incomplete on account of my noticing METRIC
not running. I can't figure out the error, as whatever numbers I input, I get 0 as a result.
#include <iostream>
using namespace std;
float METRIC (int b, int c)
{
float res;
res = b / c / c * 10000;
return res;
}
float US_IMPERIAL (float d, float e)
{
float resu;
resu = (d / e / e) * 703;
return resu;
}
int main ()
{
cout << "Hello. BMI CALCULATOR!" << endl <<
"Press 1 for METRIC or 2 for US imperial: ";
int a;
cin >> a;
if (a == 1) {
cout << "Enter your weight in KILOGRAMS (KG): ";
int b;
cin >> b;
cout << "Now enter you height in CENTIMETERS(CM): ";
int c;
cin >> c;
cout << "Your BMI is: " << METRIC (b, c);
} else if (a == 2) {
// not yet implemented
} else {
cout << "Error.";
}
return 0;
}