问题描述
我一直在做一个身高预测计算器,但是编译时遇到错误
#include <iostream>
#include <string>
using namespace std;
int main() {
int i = 0;
do {
double mom;
double dad;
string boygirl;
double fullboy = (mom * 13 / 12 + dad) / 2;
double fullgirl = (dad + 12 / 13 + mom) / 2;
double twsub = 12;
double twsub2 = 12;
cout << " \n\nWELCOME TO THE C++ HEIGHT PREDICTION PROGRAM";
cout << "\n\n INPUT GENDER TO BEGIN boy/girl: ";
cin >> boygirl;
cout << "How tall is your mother in inches: ";
cin >> mom;
cout << "How tall is your father in inches: ";
cin >> dad;
if (boygirl == "boy") {
cout << fullboy % twsub2 << "ft"
<< "is your estimated height";
}
else if (boygirl == "girl") {
cout << fullgirl % twsub << "ft"
<< " is your estimated height";
}
++i;
} while (i < 10);
}
错误是
error: invalid operands of types ‘double’ and ‘double’ to binary ‘operator%
通过以下几行代码会发生这种情况:
if (boygirl == "boy") {
cout << fullboy % twsub2 << "ft" << "is your estimated height";
}
和
else if (boygirl == "girl") {
cout << fullgirl % twsub << "ft" << " is your estimated height";
}
我想知道是否有人可以帮助我修复代码中的错误
谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)