第一题:
#include
void main()
{
float sum,price;
printf("请输入用水量:");
scanf("%f",&sum);
if(sum<=10.0)
price=sum*1.2;
else if(sum>10.0 && sum<=20.0)
price=sum*2.0;
else if(sum>20.0 && sum<=50.0)
price=sum*4.0;
else
price=sum*10.0;
printf("\n用水总价为:%6.3f元\n",price);
}
第二题:
#include
void main()
{
float money,all;
printf("请输入月工资:");
scanf("%f",&money);
if(money<=1600)
all=0;
else if(money>1600 && money<=3000)
all=money*2/100;
else if(money>3000 && money<=10000)
all=money*8/100;
else if(money>10000 && money<=50000)
all=money*12/100;
else if(money>50000 && money<=200000)
all=money*16/100;
else
all=money*20/100;
printf("\n应缴纳的税收为:%6.3f元\n",all);
}
1.
//---------------------------------------------------------------------------
#include
#define eps 1e-6
int main(void)
{
float vol;
scanf("%f",&vol);
printf("total prices:");
if (vol-10<=eps) {
printf("%f\n",vol*1.2);
}
else if (vol-20<=eps) {
printf("%f\n",vol*2);
}
else if (vol-50<=eps) {
printf("%f\n",vol*4);
}
else if (vol-50>eps) {
printf("%f\n",vol*10);
}
return 0;
}
//---------------------------------------------------------------------------
2.
//---------------------------------------------------------------------------
#include
#define eps 1e-6
int main(void)
{
float vol;
scanf("%f",&vol);
printf("taxation:");
if (vol-1600<=eps) {
printf("%f\n",0);
}
else if (vol-3000<=eps) {
printf("%f\n",vol*0.02);
}
else if (vol-10000<=eps) {
printf("%f\n",vol*0.08);
}
else if (vol-50000>eps) {
printf("%f\n",vol*0.12);
}
else if (vol-200000<=eps) {
printf("%f\n",vol*0.16);
}
else {
printf("%f\n",vol/5);
}
return 0;
}
//---------------------------------------------------------------------------