
Concept explainers
(Financial application: compute tax) Rewrite Listing 3.5, ComputeTax.java, using arrays. For each filing status, there are six tax rates. Each rate is applied to a certain amount of taxable income. For example, from the taxable income of $400,000 for a single filer, $8,350 is taxed at 10%, (33,950 − 8,350) at 15%, (82,250 − 33,950) at 25%, (171,550 − 82,550) at 28%, (372,550 − 82,250) at 33%, and (400,000 − 372,950) at 36%. The six rates are the same for all filing statuses, which can be represented in the following array:
double[] rates= {0.10, 0.15 , 0.25, 0.28 , 0.33, 0. 35};
The brackets for each rate for all the filing statuses can be represented in a two-dimensional array as follows:
Suppose the taxable income is $400,000 for single filers. The tax can be computed as follows:
tax = brackets [0][0] * rates[0] +
(brackets [0][1] − brackets [0] [0]) * rates [1] +
(brackets[0] [2] − brackets[0][1]) * rates[2] +
(brackets [0] [3] − brackets [0] [2]) * rates[3] +
(brackets [0] [4 ] − brackets[0] [3]) * rates [4] +
(400000 − brackets[0] [4]) * rates[5] ;

Want to see the full answer?
Check out a sample textbook solution
Chapter 8 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version, Student Value Edition (11th Edition)
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage




