税收方案类别

编写一程序,让用户指定缴纳的税金种类及应纳税收入,自动计算税金。 

类别税金
单身17850美元按15%计,超出部分按28%计
户主23900美元按15%计,超出部分按28%计
已婚,共有29750美元按15%计,超出部分按28%计
已婚,离异14875美元按15%计,超出部分按28%计

如:一位工资20000美元的单身人士,应缴纳的税费为0.15*7850+0.28*(20000-17850)美元。

代码:

#include<stdio.h>
#define SINGLE 17850
#define HOLDER 23900
#define MARRY 29750
#define DIVORCE 14875
#define BASE_TAX 0.15
#define EXTRA_TAX 0.28

int main(void)
{
	char type;
	float salary;
	float tax, salary_taxed;

	do
	{
		printf("Select tax type. There four type:\n");
		printf("1)single 2)house holder 3)married 4)divorced 5)quit:\n");
		scanf("%c", &type);
		switch (type)
		{
			case '1':/*单身*/
				printf("enter your salary:");
				scanf("%f", &salary);
				if (salary <= SINGLE)
				{
					tax = salary * BASE_TAX;
					salary_taxed = salary - tax;
				}
				else
				{
					tax = salary * BASE_TAX + (salary - SINGLE) * EXTRA_TAX;
					salary_taxed = salary - tax;
				}
				printf("your salary is %.2f, tax is %.2f, after tax salary is %2f\b\n", salary, tax, salary_taxed);
				break;
			case '2':/*户主*/
				printf("enter your salary:");
				scanf("%f", &salary);
				if (salary <= HOLDER)
				{
					tax = salary * BASE_TAX;
					salary_taxed = salary - tax;
				}
				else
				{
					tax = salary * BASE_TAX + (salary - HOLDER) * EXTRA_TAX;
					salary_taxed = salary - tax;
				}
				printf("your salary is %.2f, tax is %.2f, after tax salary is %2f\b\n", salary, tax, salary_taxed);
				break;
			case '3':/*已婚,共有*/
				printf("enter your salary:");
				scanf("%f", &salary);
				if (salary <= MARRY)
				{
					tax = salary * BASE_TAX;
					salary_taxed = salary - tax;
				}
				else
				{
					tax = salary * BASE_TAX + (salary - MARRY) * EXTRA_TAX;
					salary_taxed = salary - tax;
				}
				printf("your salary is %.2f, tax is %.2f, after tax salary is %2f\b\n", salary, tax, salary_taxed);
				break;
			case '4':/*离异*/
				printf("enter your salary:");
				scanf("%f", &salary);
				if (salary <= DIVORCE)
				{
					tax = salary * BASE_TAX;
					salary_taxed = salary - tax;
				}
				else
				{
					tax = salary * BASE_TAX + (salary - DIVORCE) * EXTRA_TAX;
					salary_taxed = salary - tax;
				}
				printf("your salary is %.2f, tax is %.2f, after tax salary is %2f\b\n", salary, tax, salary_taxed);
				break;
			case '5':
				break;
			default:printf("wrong type.retry.\n");
		}

	} while (type != '5');
	printf("done\n");

	return 0;

}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值