我正在尝试做一个基本的 BMI 计算器,当我做它的公制方面它工作正常,但是,英制方面返回一个错误的答案。
cout << "What is your weight? ";
cin >> weight;
cout << "What is your height in either inches or meters? ";
cin >> height;
cout << "Is that metric or imperial? Type 1 for metric, or 0 for imperial ";
cin >> unit;
if (unit = 1)
answer = weight / (height * height);
if (unit = 0)
answer = (weight * 703) / (height * height);
cout << "Your BMI is " << answer << endl;
system("PAUSE");
return 0;
根据维基百科,我认为英制的 BMI 方程是
重量(磅)* 703 /(高度平方英寸)