第6章循环4、输入多笔交易并计算佣金,输入0时终止
作者:互联网
float sum, comm;
printf("Enter value of trade: ");
scanf("%f", &sum);
while(sum != 0){
if (sum < 2500)
comm = 30 + sum * 0.017;
else if(sum < 6250)
comm = 56 + sum * 0.0066;
else if(sum < 20000)
comm = 76 + sum * 0.0034;
else if(sum < 50000)
comm = 100 + sum * 0.0022;
else if(sum < 500000)
comm = 155 + sum * 0.0011;
else
comm = 255 + sum * 0.0009;
if(comm < 39)
comm = 39;
printf("Commission: $%.2f\n", comm);
scanf("%f", &sum);
}
printf("Enter value of trade: 0");
标签:sum,Enter,else,comm,printf,多笔,佣金,trade,输入 来源: https://www.cnblogs.com/cjbsai/p/14607930.html