小编gin*_*kid的帖子

如果/ else总是转到else语句

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

c++ if-statement

16
推荐指数
2
解决办法
933
查看次数

标签 统计

c++ ×1

if-statement ×1