HW5.15


public class Solution
{
public static void main(String[] args)
{
System.out.printf("%10s\t%10s\t%10s\t%10s\t%10s\n", "Taxable", "Single", "Married", "Married", "Head of");
System.out.printf("%10s\t%10s\t%10s\t%10s\t%10s\n", "Income", " ", "Joint", "Separate", "a House");
for(int i = 50000; i <= 60000; i += 50)
System.out.printf("%10d\t%10f\t%10f\t%10f\t%10f\n", i, computeTax(0, 1.0 * i),
computeTax(1, 1.0 * i), computeTax(2, 1.0 * i), computeTax(3, 1.0 * i));
}
public static double computeTax(int status, double taxableIncome)
{
double tax = 0;
if(status == 0)
{
if(taxableIncome <= 8350)
tax = taxableIncome * 0.1;
else if(taxableIncome <= 33950)
tax = 8350 * 0.1 + (taxableIncome - 8350) * 0.15;
else if(taxableIncome <= 82250)
tax = 8350 * 0.1 + (33950 - 8350) * 0.15 + (taxableIncome - 33950) * 0.25;
else if(taxableIncome <= 171550)
tax = 8350 * 0.1 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (taxableIncome - 82250) * 0.28;
else if(taxableIncome <= 372950)
tax = 8350 * 0.1 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 +
(taxableIncome - 171550) * 0.33;
else
tax = 8350 * 0.1 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 +
(372950 - 171550) * 0.33 + (taxableIncome - 372950) * 0.35;
}
else if(status == 1)
{
if(taxableIncome <= 16700)
tax = taxableIncome * 0.1;
else if(taxableIncome <= 67900)
tax = 16700 * 0.1 + (taxableIncome - 16700) * 0.15;
else if(taxableIncome <= 137050)
tax = 16700 * 0.1 + (67900 - 16700) * 0.15 + (taxableIncome - 67900) * 0.25;
else if(taxableIncome <= 208850)
tax = 16700 * 0.1 + (67900 - 16700) * 0.15 + (137050 - 67900) * 0.25 +
(taxableIncome - 137050) * 0.28;
else if(taxableIncome <= 372950)
tax = 16700 * 0.1 + (67900 - 16700) * 0.15 + (137050 - 67900) * 0.25 +
(208850 - 137050) * 0.28 + (taxableIncome - 208850) * 0.33;
else
tax = 16700 * 0.1 + (67900 - 16700) * 0.15 + (137050 - 67900) * 0.25 +
(208850 - 137050) * 0.28 + (372950 - 208850) * 0.33 + (taxableIncome - 372950) * 0.35;
}
else if(status == 2)
{
if(taxableIncome <= 8350)
tax = taxableIncome * 0.1;
else if(taxableIncome <= 33950)
tax = 8350 * 0.1 + (taxableIncome - 8350) * 0.15;
else if(taxableIncome <= 68525)
tax = 8350 * 0.1 + (33950 - 8350) * 0.15 + (taxableIncome - 33950) * 0.25;
else if(taxableIncome <= 104425)
tax = 8350 * 0.1 + (33950 - 8350) * 0.15 + (68525 - 33950) * 0.25 + (taxableIncome - 68525) * 0.28;
else if(taxableIncome <= 186475)
tax = 8350 * 0.1 + (33950 - 8350) * 0.15 + (68525 - 33950) * 0.25 + (104425 - 68525) * 0.28 +
(taxableIncome - 104425) * 0.33;
else
tax = 8350 * 0.1 + (33950 - 8350) * 0.15 + (68525 - 33950) * 0.25 + (104425 - 68525) * 0.28 +
(186475 - 104425) * 0.33 + (taxableIncome - 186475) * 0.35;
}
else if(status == 3)
{
if(taxableIncome <= 11950)
tax = taxableIncome * 0.1;
else if(taxableIncome <= 45500)
tax = 11950 * 0.1 + (taxableIncome - 11950) * 0.15;
else if(taxableIncome <= 117450)
tax = 11950 * 0.1 + (45500 - 11950) * 0.15 + (taxableIncome - 45500) * 0.25;
else if(taxableIncome <= 190200)
tax = 11950 * 0.1 + (45500 - 11950) * 0.15 + (117450 - 45500) * 0.25 +
(taxableIncome - 117450) * 0.28;
else if(taxableIncome <= 372950)
tax = 11950 * 0.1 + (45500 - 11950) * 0.15 + (117450 - 45500) * 0.25 +
(190200 - 117450) * 0.28 + (taxableIncome - 190200) * 0.33;
else
tax = 11950 * 0.1 + (45500 - 11950) * 0.15 + (117450 - 45500) * 0.25 +
(190200 - 117450) * 0.28 + (372950 - 190200) * 0.33 + (taxableIncome - 372950) * 0.35;
}
return tax;
}
}
HW5.15的更多相关文章
- .NET平台开源项目速览(15)文档数据库RavenDB-介绍与初体验
不知不觉,“.NET平台开源项目速览“系列文章已经15篇了,每一篇都非常受欢迎,可能技术水平不高,但足够入门了.虽然工作很忙,但还是会抽空把自己知道的,已经平时遇到的好的开源项目分享出来.今天就给大家 ...
- 15个关于Chrome的开发必备小技巧[译]
谷歌Chrome,是当前最流行且被众多web开发人员使用的浏览器.最快六周就更新发布一次以及伴随着它不断强大的开发组件,使得Chrome成为你必备的开发工具.例如,在线编辑CSS,console以及d ...
- 15个C++项目列表
实验楼上有很多C++的实战项目,从简单到进阶,学习每个项目都可以掌握相应的知识点. 如果你还是C++新手的话,那么这个C++的项目列表你可以拿去练手实战开发,毕竟学编程动手实践是少不了的! 如果你不知 ...
- Hacker Rank: Two Strings - thinking in C# 15+ ways
March 18, 2016 Problem statement: https://www.hackerrank.com/challenges/two-strings/submissions/code ...
- 在 Ubuntu 15.04 中使用 ubuntu-make、Eclipse 4.4、Java 8 以及 WTP
Ubuntu 今天发布新版本了 其实昨天(2015-04-23)我就看到了 Ubuntu 发布新版本的新闻,下班后回家的第一件事就是访问 Ubuntu 的官网,很可惜,没有提供下载.今天(2015-0 ...
- 企业IT管理员IE11升级指南【15】—— 代理自动配置脚本
企业IT管理员IE11升级指南 系列: [1]—— Internet Explorer 11增强保护模式 (EPM) 介绍 [2]—— Internet Explorer 11 对Adobe Flas ...
- (转)C++语言的15个晦涩特性
原文链接: Evan Wallace 翻译: 伯乐在线- 敏敏 译文链接: http://blog.jobbole.com/54140/ 这个列表收集了 C++ 语言的一些晦涩(Obscure)特 ...
- CSharpGL(15)用GLSL渲染2种类型的文字
CSharpGL(15)用GLSL渲染2种类型的文字 2016-08-13 由于CSharpGL一直在更新,现在这个教程已经不适用最新的代码了.CSharpGL源码中包含10多个独立的Demo,更适合 ...
- ABP(现代ASP.NET样板开发框架)系列之15、ABP应用层——应用服务(Application services)
点这里进入ABP系列文章总目录 基于DDD的现代ASP.NET开发框架--ABP系列之15.ABP应用层——应用服务(Application services) ABP是“ASP.NET Boiler ...
随机推荐
- 021,lambda 表达式
021,lambda 表达式 匿名函数: 快速定义单行的最小函数,是从lisp借用来的,可以用在任何需要函数的地方 >>> def ds(x): return 2*x + ...
- 折腾了一早上的C# WPF ListView+Grid 实现图片+文字 自动换行排列 类似Windows资源管理器效果
<ListBox Name="lstFileManager" Background ="Transparent" ItemsSource="{B ...
- MVC-简单验证码制作
1.制作验证码: using System; using System.Collections.Generic; using System.Drawing; using System.Drawing. ...
- ionic+angulajs
基于ionic+angulajs的混合开发实现地铁APP 项目源码地址:https://github.com/zhangxy1035/SubwayMap 一.项目简介 在该项目中的地铁app是基于io ...
- Amazon Alexa 语音识别1 : 简介
Alexa是Amazon自家的语音识别技术,需要配合自家的Echo音箱使用.开发者可以在Amazon上建立自己的程序(Skill)来连接到自己的应用或是硬件.例如,用户家里有一套xx牌的智能灯,现在希 ...
- 学无止境,学习AJAX(二)
POST 请求 一个简单 POST 请求: xmlhttp.open("POST","demo_post.asp",true); xmlhttp.send(); ...
- python 常用模块(转载)
转载地址:http://codeweblog.com/python-%e5%b8%b8%e7%94%a8%e6%a8%a1%e5%9d%97/ adodb:我们领导推荐的数据库连接组件bsddb3:B ...
- How To Call Stored Procedure In Hibernate
How To Call Stored Procedure In Hibernate In this tutorial, you will learn how to call a store proce ...
- [XJOI NOI2015模拟题13] A 神奇的矩阵 【分块】
题目链接:XJOI NOI2015-13 A 题目分析 首先,题目定义的这种矩阵有一个神奇的性质,第 4 行与第 2 行相同,于是第 5 行也就与第 3 行相同,后面的也是一样. 因此矩阵可以看做只有 ...
- Ubuntu下使用ap-hotspot出现“Another process is already running"问题的解决方案
参考Problem with ap-hotspot 问题描述: This is the message displayed in my terminal screen when I typed sud ...