c++用switch写利润提成
时间: 2024-06-11 17:00:55 浏览: 65
以下是使用C++的switch语句来计算利润提成的代码:
```
#include <iostream>
using namespace std;
int main() {
double I, bonus;
cout << "请输入当年利润I:";
cin >> I;
switch ((int)I / 100000) {
case 0:
bonus = I * 0.1;
break;
case 1:
bonus = 10000 + (I - 100000) * 0.075;
break;
case 2:
case 3:
bonus = 17500 + (I - 200000) * 0.05; break;
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
bonus = 27500 + (I - 400000) * 0.03;
break;
default:
bonus = 65500 + (I - 1000000) * 0.01;
break;
}
cout << "应发放奖金总数为:" << bonus << "元" << endl;
return 0;
}
```
阅读全文