码迷,mamicode.com
首页 > 其他好文 > 详细

HW5.15

时间:2016-08-21 12:27:19      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

技术分享

 

 1 public class Solution
 2 {
 3     public static void main(String[] args)
 4     {
 5         System.out.printf("%10s\t%10s\t%10s\t%10s\t%10s\n", "Taxable", "Single", "Married", "Married", "Head of");
 6         System.out.printf("%10s\t%10s\t%10s\t%10s\t%10s\n", "Income", " ", "Joint", "Separate", "a House");
 7 
 8         for(int i = 50000; i <= 60000; i += 50)
 9             System.out.printf("%10d\t%10f\t%10f\t%10f\t%10f\n", i, computeTax(0, 1.0 * i), 
10                 computeTax(1, 1.0 * i), computeTax(2, 1.0 * i), computeTax(3, 1.0 * i));
11     }
12 
13     public static double computeTax(int status, double taxableIncome)
14     {
15         double tax = 0;
16 
17         if(status == 0)
18         {
19             if(taxableIncome <= 8350)
20                 tax = taxableIncome * 0.1;
21             else if(taxableIncome <= 33950)
22                 tax = 8350 * 0.1 + (taxableIncome - 8350) * 0.15;
23             else if(taxableIncome <= 82250)
24                 tax = 8350 * 0.1 + (33950 - 8350) * 0.15 + (taxableIncome - 33950) * 0.25;
25             else if(taxableIncome <= 171550)
26                 tax = 8350 * 0.1 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (taxableIncome - 82250) * 0.28;
27             else if(taxableIncome <= 372950)
28                 tax = 8350 * 0.1 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + 
29                 (taxableIncome - 171550) * 0.33;
30             else
31                 tax = 8350 * 0.1 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + 
32                 (372950 - 171550) * 0.33 + (taxableIncome - 372950) * 0.35;
33         }
34 
35         else if(status == 1)
36         {
37             if(taxableIncome <= 16700)
38                 tax = taxableIncome * 0.1;
39             else if(taxableIncome <= 67900)
40                 tax = 16700 * 0.1 + (taxableIncome - 16700) * 0.15;
41             else if(taxableIncome <= 137050)
42                 tax = 16700 * 0.1 + (67900 - 16700) * 0.15 + (taxableIncome - 67900) * 0.25;
43             else if(taxableIncome <= 208850)
44                 tax = 16700 * 0.1 + (67900 - 16700) * 0.15 + (137050 - 67900) * 0.25 + 
45                 (taxableIncome - 137050) * 0.28;
46             else if(taxableIncome <= 372950)
47                 tax = 16700 * 0.1 + (67900 - 16700) * 0.15 + (137050 - 67900) * 0.25 + 
48                 (208850 - 137050) * 0.28 + (taxableIncome - 208850) * 0.33;
49             else
50                 tax = 16700 * 0.1 + (67900 - 16700) * 0.15 + (137050 - 67900) * 0.25 + 
51                 (208850 - 137050) * 0.28 + (372950 - 208850) * 0.33 + (taxableIncome - 372950) * 0.35;
52         }
53 
54         else if(status == 2)
55         {
56             if(taxableIncome <= 8350)
57                 tax = taxableIncome * 0.1;
58             else if(taxableIncome <= 33950)
59                 tax = 8350 * 0.1 + (taxableIncome - 8350) * 0.15;
60             else if(taxableIncome <= 68525)
61                 tax = 8350 * 0.1 + (33950 - 8350) * 0.15 + (taxableIncome - 33950) * 0.25;
62             else if(taxableIncome <= 104425)
63                 tax = 8350 * 0.1 + (33950 - 8350) * 0.15 + (68525 - 33950) * 0.25 + (taxableIncome - 68525) * 0.28;
64             else if(taxableIncome <= 186475)
65                 tax = 8350 * 0.1 + (33950 - 8350) * 0.15 + (68525 - 33950) * 0.25 + (104425 - 68525) * 0.28 + 
66                 (taxableIncome - 104425) * 0.33;
67             else
68                 tax = 8350 * 0.1 + (33950 - 8350) * 0.15 + (68525 - 33950) * 0.25 + (104425 - 68525) * 0.28 + 
69                 (186475 - 104425) * 0.33 + (taxableIncome - 186475) * 0.35;
70         }
71 
72         else if(status == 3)
73         {
74             if(taxableIncome <= 11950)
75                 tax = taxableIncome * 0.1;
76             else if(taxableIncome <= 45500)
77                 tax = 11950 * 0.1 + (taxableIncome - 11950) * 0.15;
78             else if(taxableIncome <= 117450)
79                 tax = 11950 * 0.1 + (45500 - 11950) * 0.15 + (taxableIncome - 45500) * 0.25;
80             else if(taxableIncome <= 190200)
81                 tax = 11950 * 0.1 + (45500 - 11950) * 0.15 + (117450 - 45500) * 0.25 + 
82                 (taxableIncome - 117450) * 0.28;
83             else if(taxableIncome <= 372950)
84                 tax = 11950 * 0.1 + (45500 - 11950) * 0.15 + (117450 - 45500) * 0.25 + 
85                 (190200 - 117450) * 0.28 + (taxableIncome - 190200) * 0.33;
86             else
87                 tax = 11950 * 0.1 + (45500 - 11950) * 0.15 + (117450 - 45500) * 0.25 + 
88                 (190200 - 117450) * 0.28 + (372950 - 190200) * 0.33 + (taxableIncome - 372950) * 0.35;
89         }
90 
91         return tax;
92     }
93 }

 

HW5.15

标签:

原文地址:http://www.cnblogs.com/wood-python/p/5792331.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!