问题标题: 酷町堂:1753

0
0

0
已采纳
杨陈卓
杨陈卓
新手天翼
新手天翼
    if (a<=3500)b=0.00;
    if(a<=5000&&a>3500)b=(a-3500)*0.03;
    if(a<=8000&&a>5000)b=(5000-3500)*0.03+(a-5000)*0.1;
    if(a<=12500&&a>8000)b=(5000-3500)*0.03+(8000-5000)*0.1+(a-8000)*0.2;
    if(a<=38500&&a>12500)b=(5000-3500)*0.03+(8000-5000)*0.1+(12500-8000)*0.2+(a-12500)*0.25;
    if(a<=58500&&a>38500)b=(5000-3500)*0.03+(8000-5000)*0.1+(12500-8000)*0.2+(38500-12500)*0.25+(a-38500)*0.3;
    if(a<=83500&&a>58500)b=(5000-3500)*0.03+(8000-5000)*0.1+(12500-8000)*0.2+(38500-12500)*0.25+(58500-38500)*0.3+(a-58500)*0.35;
    if(a>83500)b=(5000-3500)*0.03+(8000-5000)*0.1+(12500-8000)*0.2+(38500-12500)*0.25+(58500-38500)*0.3+(83500-58500)*0.35+(a-83500)*0.45;

核心代码

输出要四舍五入

0
朱宇辰
朱宇辰
初级守护
初级守护

这应该几个if就解决了,我举个例子

if(x<=3500)

 (.......)

else if(x<=5000)

(........)

else if(x<=8000)

(.......以此类推)

省略号部分就是对税收的计算了,比如第三个括号部分填:

w+=1500*0.03+(x-5000)*0.1

朱宇辰在2018-02-04 13:24:20追加了内容

感谢前面那位好心的老兄,把代码写出来了,那我就简化并修改一下吧。

if (a<=3500)b=0.00;
    else if(a<=5000)b=(a-3500)*0.03;
    else if(a<=8000)b=(5000-3500)*0.03+(a-5000)*0.1;
    else if(a<=12500)b=(5000-3500)*0.03+(8000-5000)*0.1+(a-8000)*0.2;
    else if(a<=38500)b=(5000-3500)*0.03+(8000-5000)*0.1+(12500-8000)*0.2+(a-12500)*0.25;
    else if(a<=58500))b=(5000-3500)*0.03+(8000-5000)*0.1+(12500-8000)*0.2+(38500-12500)*0.25+(a-38500)*0.3;
    else if(a<=83500)b=(5000-3500)*0.03+(8000-5000)*0.1+(12500-8000)*0.2+(38500-12500)*0.25+(58500-38500)*0.3+(a-58500)*0.35;
    else if(a>83500)b=(5000-3500)*0.03+(8000-5000)*0.1+(12500-8000)*0.2+(38500-12500)*0.25+(58500-38500)*0.3+(83500-58500)*0.35+(a-83500)*0.45;

0
臧启亚
臧启亚
初级光能
初级光能

核心代码

 if (a<=3500)b=0;
    else if (a<=5000)b=(a-3500)*0.03;
    else if (a<=8000)b=(5000-3500)*0.03+(a-5000)*0.1;
    else if (a<=12500)b=(5000-3500)*0.03+(8000-5000)*0.1+(a-8000)*0.2;
    else if (a<=38500)b=(5000-3500)*0.03+(8000-5000)*0.1+(12500-8000)*0.2+(a-12500)*0.25;
    else if (a<=58500)b=(5000-3500)*0.03+(8000-5000)*0.1+(12500-8000)*0.2+(38500-12500)*0.25+(a-38500)*0.3;
    else if (a<=83500)b=(5000-3500)*0.03+(8000-5000)*0.1+(12500-8000)*0.2+(38500-12500)*0.25+(58500-38500)*0.3+(a-58500)*0.35;
    else if (a>83500)b=(5000-3500)*0.03+(8000-5000)*0.1+(12500-8000)*0.2+(38500-12500)*0.25+(58500-38500)*0.3+(83500-58500)*0.35+(a-83500)*0.45;
    printf("%.2f",b);

 

0
我要回答