急急急,C++ 输入一个奖金数,求税率、应交税款及实得奖金数
答案:3 悬赏:0 手机版
解决时间 2021-01-26 05:20
- 提问者网友:嘚啵嘚啵
- 2021-01-26 02:12
奖金税率如下:(a代表奖金,r代表税率) a<100(元) r=0% 100≤a<200 r=2% 200≤a<400 r=4% 400≤a<800 r=8% a≥800 r=10%
最佳答案
- 五星知识达人网友:患得患失的劫
- 2021-01-26 03:21
||
#include <stdio.h>
#define RANK_MAX 4
double rate[RANK_MAX+1] = {0.0, 0.02, 0.04, 0.08, 0.10};
double rank[RANK_MAX] = {100, 200, 400 ,800};
void TaxCalculating(double bonus)
{
int i, j;
double pay = 0, rest = 0;
if( bonus<0 )
{
printf("数据错误.\n");
return;
}
for( i=0; i<RANK_MAX; i++ )
{
if( bonus<=rank[i] )
break;
}
pay = bonus * rate[i];
pay = pay - rank[0]*rate[i];
for( j=1; j<i; j++ )
{
pay -= (rank[j] - rank[j-1]) * (rate[i] - rate[j]);
}
rest = bonus - pay; printf("奖金数:%.2f\n税率:%.2f\n应缴税款:%.2f\n实得奖金:%.2f\n", bonus, rate[i], pay, rest );
return;}
void main()
{
char ans;
double bonus;
do
{
printf("请输入奖金数:");
scanf("%lf", &bonus);
fflush(stdin);
TaxCalculating(bonus);
printf("Go on?(y or Y)?\n");
scanf("%c", &ans);
fflush(stdin);;
} while ( ans=='y' || ans=='Y');
return;}
#include <stdio.h>
#define RANK_MAX 4
double rate[RANK_MAX+1] = {0.0, 0.02, 0.04, 0.08, 0.10};
double rank[RANK_MAX] = {100, 200, 400 ,800};
void TaxCalculating(double bonus)
{
int i, j;
double pay = 0, rest = 0;
if( bonus<0 )
{
printf("数据错误.\n");
return;
}
for( i=0; i<RANK_MAX; i++ )
{
if( bonus<=rank[i] )
break;
}
pay = bonus * rate[i];
pay = pay - rank[0]*rate[i];
for( j=1; j<i; j++ )
{
pay -= (rank[j] - rank[j-1]) * (rate[i] - rate[j]);
}
rest = bonus - pay; printf("奖金数:%.2f\n税率:%.2f\n应缴税款:%.2f\n实得奖金:%.2f\n", bonus, rate[i], pay, rest );
return;}
void main()
{
char ans;
double bonus;
do
{
printf("请输入奖金数:");
scanf("%lf", &bonus);
fflush(stdin);
TaxCalculating(bonus);
printf("Go on?(y or Y)?\n");
scanf("%c", &ans);
fflush(stdin);;
} while ( ans=='y' || ans=='Y');
return;}
全部回答
- 1楼网友:duile
- 2021-01-26 03:55
if (a>=100 && a <200)
{
cout<<"税率r=2%"<<endl;
cout<<"应交税款 = "<<a*0.2<<endl;
cout<<"实得奖金数"<<a*0.98<<endl;
}
依次这样判断...
- 2楼网友:怀裏藏嬌
- 2021-01-26 03:27
#include <stdio.h>
#define rank_max 4
double rate[rank_max+1] = {0.0, 0.02, 0.04, 0.08, 0.10};
double rank[rank_max] = {100, 200, 400 ,800};
void taxcalculating(double bonus)
{
int i, j;
double pay = 0, rest = 0;
if( bonus<0 )
{
printf("数据错误.\n");
return;
}
for( i=0; i<rank_max; i++ )
{
if( bonus<=rank[i] )
break;
}
pay = bonus * rate[i];
pay = pay - rank[0]*rate[i];
for( j=1; j<i; j++ )
{
pay -= (rank[j] - rank[j-1]) * (rate[i] - rate[j]);
}
rest = bonus - pay; printf("奖金数:%.2f\n税率:%.2f\n应缴税款:%.2f\n实得奖金:%.2f\n", bonus, rate[i], pay, rest );
return;}
void main()
{
char ans;
double bonus;
do
{
printf("请输入奖金数:");
scanf("%lf", &bonus);
fflush(stdin);
taxcalculating(bonus);
printf("go on?(y or y)?\n");
scanf("%c", &ans);
fflush(stdin);;
} while ( ans=='y' || ans=='y');
return;}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯