求解答
if else语句做的对不对,switch怎么做的,求思路

if else语句做的对不对,switch怎么做的,求思路

2017-04-20
#include <stdio.h>
void main()
{
float I;
int a;
printf("请输入本月利润:");
scanf("%f",&I);
a=(int)I;
switch(a=a/100000)
{
case 0:printf("奖金为%.2f",I*0.1);
break;
case 1:
if(I==100000)
printf("奖金为%.2f",I*0.1);
else
printf("奖金为%.2f",10000+(I-100000)*0.075);
break;
case 2:
if(I==200000)
printf("奖金为%.2f",17500);
else
printf("奖金为%.2f",17500+(I-200000)*0.05);
break;
case 3:printf("奖金为%.2f",17500+(I-200000)*0.05);
break;
case 4:
if(I==400000)
printf("奖金为%.2f",27500);
else
printf("奖金为%.2f",27500+(I-400000)*0.03);
break;
case 5:printf("奖金为%.2f",27500+(I-400000)*0.03);
break;
case 6:
if(I==600000)
printf("奖金为%.2f",33500);
else
printf("奖金为%.2f",33500+(I-600000)*0.015);
break;
case 7:
case 8:
case 9: printf("奖金为%.2f",33500+(I-600000)*0.015);
break;
case 10:
if(I==1000000)
printf("奖金为%.2f",39500);
else
printf("奖金为%.2f",39500+(I-1000000)*0.01);
break;
default:printf("奖金为%.2f",39500+(I-1000000)*0.01);
}
}举报