我正在尝试根据用户输入的金额制作一个确定佣金的功能.它需要用户输入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;
}
}
Run Code Online (Sandbox Code Playgroud)