纳税

题目:
       在美国,不同的税率是根据纳税人的婚姻状况而定的。单身和已婚的纳税人有不同的税收计划。已婚的纳税人将他们的收入加在一起,并支付总的税。如下表计算税率。不同税率适合于每一个“分支”。在表中,第一个分支的收入为10%,第二个分支的收入为25%。每个分支的收入范围取决于婚姻状况。

税率表
if your status is single and if the taxable income isthe tax isof the amount over
<=$32,00010%$0
>$32,000$3,200+25%$32,000
if your status is married and if the taxable income isthe tax isof the amount over
<=$64,00010%$0
>64,000$6,400+25%$64,000

 

代码:

import java.util.Scanner;
public class taxRate 
{
	
	private static Scanner in;

	public static void main(String[] args)
	{
		final double rate1 = 0.10;
		final double rate2 = 0.25;
		final double singleLimit = 32000;
		final double marriedLimit = 64000;
		double tax1 = 0;
		double tax2 = 0;
		in = new Scanner(System.in);
		System.out.print("please input your income:");
		double income = in.nextDouble();
		System.out.print("please input s for single or m for married:");
		String maritalStatue = in.next();
		if(maritalStatue.equals("s"))
		{
			if(income<=singleLimit)
			{
				tax1 = rate1 * income;
			}
			else
			{
				tax1 = rate1 * singleLimit;
				tax2 = rate2 * (income - singleLimit);
			}
		}
		else
		{
			if(income<=marriedLimit)
			{
				tax1 = rate1 * income;
			}
			else
			{
				tax1 = rate1 * marriedLimit;
				tax2 = rate2 * (income - marriedLimit);
			}
		}
		double totalTax = tax1 + tax2;
		System.out.println("The tax is $"+totalTax);
	}
	
}

运行结果:

 

 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值