我一直在制作高度预测计算器,但编译时出现错误
#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";
}
我想知道是否有人可以帮我解决我的代码中的这个错误
谢谢