#include "stdio.h"
#include "stdlib.h"
int main()
{float li,jiang;
printf("Input li:\n");
scanf("%f",&li);
while(li<=0)
{printf("Data Wrong!\n");system("pause");return 0;}
if(li<=10)jiang=0.1*li;
else if(li>=10&&li<=20)jiang=0.1*10+0.075*(li-10);
else if(li>=20&&li<=40)jiang=0.1*10+0.075*10+0.05*(li-20);
else if(li>=40&&li<=60)jiang=0.1*10+0.075*10+0.05*20+0.03*(li-40);
else if(li>=60&&li<=100)jiang=0.1*10+0.075*10+0.05*20+0.03*20+0.015*(li-60);
else jiang=0.1*10+0.075*10+0.05*20+0.03*20+0.015*40+0.01*(li-100);
printf("jiang is:%.3f",jiang);
system("pause");
}
1.可把各阶段的常数资金分别命名j1,j2,j3等
2.else后只加<=即可
3.注意long,float,int,double在用法上的区别,复习%8.3f的含义
时间: 2024-10-20 09:33:23