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 ...
随机推荐
- STL的pair学习, map学习
http://blog.csdn.net/calvin_zcx/article/details/6072286 http://www.linuxidc.com/Linux/2014-10/107621 ...
- 角色控制器 Character Controller
Unity中,1个单位尺寸代表1米.即在Unity中创建一个Cube的尺寸是1x1x1米大小. Unity推荐把人的身高定为大约2个Unity单位高度(2米). 为了截取角色的全身照,需要把角色Ins ...
- spring IOC源码分析(2)
refresh这个方法包含了整个BeanFactory初始化的过程,定位资源由obtainFreshBeanFactory()来完成, protected ConfigurableListableBe ...
- 什么是UI控件
凡是带有Widget参数的组件都是控件.
- node.js 1Million concurrent connections!
https://github.com/ashtuchkin/node-millenium http://blog.caustik.com/2012/08/19/node-js-w1m-concurre ...
- 重置mysql密码
如何修改mysql root密码 忘记MySQL ROOT密码是在MySQ使用中很常见的问题,可是有很多朋友并不会重置ROOT密码,那叫苦啊,特写此文章与大家交流: 1.编辑MySQL的配置文件:my ...
- CSS3 animation的steps方式过渡
animation默认以ease方式过渡,它会在每个关键帧之间插入补间动画,所以动画效果 是连贯性的.除了ease,linear.cubic-bezier之类的过渡函数都会为其插入补间. 但有些效果不 ...
- CSS 元素透明
1.HTML 元素透明 其实本身,CSS 实现元素透明是件容易事儿.直接上代码: opacity:.5 opacity 指的是不透明度,取值为 0~1 之间,1 表示完全不透明,0 表示完全透明. A ...
- Android版:验证手机号码的正则表达式
http://blog.csdn.net/dai_zhenliang/article/details/8186249 /** * 验证手机格式 */ public static boolean isM ...
- 练习PYTHON之EPOLL
哟,哟,哟,,SELECT,EPOLL之类的,终于出现了. 不能太急了,要缓一缓,缓一缓,再缓一缓~~~~~~~~~ http://scotdoyle.com/python-epoll-howto.h ...