1. Create a class named TaxCalculator with the following: a. A double data type variable named "annuallncome". b. A double data type array containing the following values in this order: 0, .1, .15, .23, .28, .33, .35 c. A method which takes annual income as a parameter and prints the tax calculate per the below tax bracket:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Question is in attatchment. Thanks!

1. Create a class named TaxCalculator with the following:
a. A double data type variable named "annuallncome".
b. A double data type array containing the following values in this order:
0, .1, .15, .23, .28, .33, .35
C. A method which takes annual income as a parameter and prints the tax calculated as
per the below tax bracket:
i.
Tax brackets:
Tax Bracket 0: Income <= 0
Tax Bracket 1:0< income <= 9999
Tax Bracket 2: 9999 < income <= 39999
Tax Bracket 3: 39999 < income <= 89999
Tax Bracket 4: 89999 < income <= 189999
Tax Bracket 5: 189999 < income <= 399999
Tax Bracket 6: 399999 < income
Conditionally check 1 of the 8 different income brackets given above to find
where the user's income falls.
ii.
Assume the array elements (from 1.b above) match with these income
brackets sequentially (i.e, if your bracket is 0 < income <= 9999 then the tax
rate is .1, which is the 2nd element in your array), calculate and print the
amount of tax they will pay
- where a users' tax will is calculated as annual income * tax rate
ii.
iv.
For example, if annual income is $200,000, which falls in tax bracket 5, then
tax rate would be .33 & therefore the tax paid would be $66,000... Ouch!
2. Create another class TaxCalculatorDemo. In that:
a. Make an object of TaxCalculator class.
b. Take annual income as input from the user and set to object's annuallncome and
print the total tax to be paid.
c. Use try...catch block while taking the user's annual income and if the user enters a
"non-double" input (like string), then print "Invalid income entered".
d. Show output for valid and invalid user entry.
Transcribed Image Text:1. Create a class named TaxCalculator with the following: a. A double data type variable named "annuallncome". b. A double data type array containing the following values in this order: 0, .1, .15, .23, .28, .33, .35 C. A method which takes annual income as a parameter and prints the tax calculated as per the below tax bracket: i. Tax brackets: Tax Bracket 0: Income <= 0 Tax Bracket 1:0< income <= 9999 Tax Bracket 2: 9999 < income <= 39999 Tax Bracket 3: 39999 < income <= 89999 Tax Bracket 4: 89999 < income <= 189999 Tax Bracket 5: 189999 < income <= 399999 Tax Bracket 6: 399999 < income Conditionally check 1 of the 8 different income brackets given above to find where the user's income falls. ii. Assume the array elements (from 1.b above) match with these income brackets sequentially (i.e, if your bracket is 0 < income <= 9999 then the tax rate is .1, which is the 2nd element in your array), calculate and print the amount of tax they will pay - where a users' tax will is calculated as annual income * tax rate ii. iv. For example, if annual income is $200,000, which falls in tax bracket 5, then tax rate would be .33 & therefore the tax paid would be $66,000... Ouch! 2. Create another class TaxCalculatorDemo. In that: a. Make an object of TaxCalculator class. b. Take annual income as input from the user and set to object's annuallncome and print the total tax to be paid. c. Use try...catch block while taking the user's annual income and if the user enters a "non-double" input (like string), then print "Invalid income entered". d. Show output for valid and invalid user entry.
Expert Solution
steps

Step by step

Solved in 5 steps with 4 images

Blurred answer
Knowledge Booster
Types of Security Models
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education