c primer plus 7.12.10

本文介绍了一个用C语言编写的程序,用于根据不同的收入类别(单身、家庭、已婚和离婚)计算所得税。根据月收入的不同阶段,采用不同的税率计算税金。
摘要由CSDN通过智能技术生成
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main(void)
{
    uint32_t kind;
    float money, tax =0;
    uint32_t single = 1, household = 2, married = 3, divorce = 4;
    puts("请输入收入");
    scanf_s("%f", &money);
    puts("请输入类别");
    scanf_s("%" PRIu32 "", &kind);
    switch (kind)
    {
    case 1: if (money < 17850)
    {
        tax = money * 0.15;
    }
          else
    {
        tax = 2677.5 + (money - 17850) * 0.28;
    }
          break;
    case 2: if (money < 23900)
    {
        tax = money * 0.15;
    }
          else
    {
        tax = 3585.0 + (money - 23900) * 0.28;
    }
          break;
    case 3: if (money < 29750)
    {
        tax = money * 0.15;
    }
          else
    {
        tax = 4462.5 + (money - 29750) * 0.28;
    }
          break;
    case 4: if (money < 14875)
    {
        tax = money * 0.15;
    }
          else
    {
        tax = 2231.25 + (money - 14875) * 0.28;
    }
          break;
    default: printf("无效输入,请重新输入\n");
        return 1;
    }

    printf("所缴税金为%.2f", tax);
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值