如何用vc++计算企业利润提成?
1、#include<stdio.h>
int main()
{
int profit,b;
double a;
printf("请输入你的利润:");
scanf("%d",&profit);
if(profit<=100000)
a=profit*0.1;
else if(profit>1e+05&&profit<=2e+05)
a=(profit-1+05)*0.075+1e+05*0.1;
else if(profit>2e+05&&profit<=4e+05)
a=(profit-2e+05)*0.05+1e+05*(0.075+0.1);
else if(profit>400000&&profit<=6e+05)
a=(profit-4e+05)*0.03+2e+05*0.05+1e+05*(0.075+0.1);
else if(profit>6e+05&&profit<=1e+06)
a=(profit-6e+05)*0.015+2e+05*(0.03+0.05)+1e+05*(0.075+0.1);
else
a=(profit-1e+06)*0.01+4e+05*0.015+2e+05*(0.03+0.05)+1e+05*(0.075+0.1);
printf("%.2lf\n\n\n\n\n",a);
2、b=profit/100000;
switch(b)
{case 0:a=profit*0.1;break;
case 1:a=(profit-1+05)*0.075+1e+05*0.1;break;
case 2:
case 3:a=(profit-2e+05)*0.05+1e+05*(0.075+0.1);break;
case 4:
case 5:a=(profit-4e+05)*0.03+2e+05*0.05+1e+05*(0.075+0.1);break;
case 6:
case 7:
case 8:
case 9:a=(profit-6e+05)*0.01+2e+05*(0.03+0.01)+1e+05*(0.075+0.1);break;
default:a=(profit-1e+06)*0.01+4e+05*0.015+2e+05*(0.03+0.01)+1e+05*(0.075+0.1);}
printf("%.2lf\n",a);
return 0;
}
3、纸质版本
4、给程序运行结果:如下