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 ...
随机推荐
- controller.pp 各组件的安装顺序
controller 属性: admin_address => $controller_node_address, public_address => $c ...
- 在树莓派上部署asp.net
今天成功的在树莓派上部署asp.net呢.之前在unbuntu上测试成功了,结果今天操作的时候又不会操作了,主要对Linux太不熟悉了,找资料,资料又不多,这次赶紧记录下来,以备下次查阅. 我用的mo ...
- C# dynamic
[TestMethod] public void DynamicTest() { dynamic Customer = new ExpandoObject(); Customer.Name = &qu ...
- Google考虑抛弃Cookies机制
根据华尔街日报的报道,Google 正在考虑抛弃古老的浏览器 cookies 来追踪用户信息的机制.作为替代,Google 将开发一种「个人匿名标识机制」.Google 早前已经计划在 IE 和 iP ...
- 用 JMH 检测 Lambdas 序列化性能
本文将介绍如何进行 Java Lambdas 序列化性能检测.Lambdas 的重要性以及 Lambdas 在分布式系统中的应用. Lambdas 表达式是 Java 8 中万众期待的新特性,其若干用 ...
- Cygwin环境编译/usr/include/sys/_types.h:72:20: 致命错误:stddef.h:can not found
环境介绍: win7_x64 +Cygwin64 gcc :4.8.2 g++:4.8.1 编译 c++的helloworld.cpp 一直失败! 代码如下: #include <iostrea ...
- android 提示用户是否退出应用程序 提升用户体验
首先明确一点,用户的一直点击的返回键,之后就会退出到桌面.那么,如何提示呢?很简单,在用户一顿返回键回到程序入口处(即程序的第一个Activity)给用户一个提示,您再按可就退出程序啦?那么如何在程序 ...
- 【Xamarin挖墙脚系列:现有IPhone/IPad 设备尺寸】
原文:[Xamarin挖墙脚系列:现有IPhone/IPad 设备尺寸]
- 如何查看自己运行ubuntu是32位还是64位
当安装ubuntu在pc上,不推荐在32位pc安装64位操作系统,64位pc安装32位操作系统 方法/步骤 按ctrl+shift+t 快捷键,打开终端,输入sudo uname --m ,按下ent ...
- Inventory > INV.MTL_MATERIAL_TRANSACTIONS Show Error Msg: ORA-20100: File lxxx.tmp creation for FND_FILE failed.
Fixed Step. 1. Backup error data CREATE TABLE MMT_BACKUP_0805 AS SELECT * FROM INV.MTL_MATERIAL_T ...