我试图做一个函数,根据用户输入的金额来确定佣金。它需要一个用户输入double,并用它来确定它使用哪个方程。但是我写的代码总是去往else语句,我不确定我的条件有什么问题。如果/其他如果总是去其他语句
double calculate(double s)
{
double c;
if (s > 300,000)
{
c = 25,000 + (0.15 * (s-300,000));
cout << "went to if" << endl;
return c;
}
else if (300,000 > s && s > 100,000)
{
c = 5,000 + (0.10 * (s-100,000));
cout << "went to else if" << endl;
return c;
}
else
{
c = 0.05 * s;
cout << "went to else" << endl;
return c;
}
}
@krzaq如何?真的吗? –
@πάνταῥεῖ都是关于操作符','的误用。 – krzaq
@ krzaq也许,但不够明显的愚蠢。来吧。 –