Question
Java Millions of innocent Americans are filling in their 1040. Don't we all just love the IRS. If I were king, things would be a
Java
Millions of innocent Americans are filling in their 1040. Don't we all just love the IRS. If I were king, things would be a whole bunch simpler, with a simple computer program to compute tax. Here's how the IRS program would work:
- The loyal subject is repeatedly prompted to enter either an amount of income (a positive value) or an amount of deduction (a negative value). This continues until a zero value is entered. The positive values are summed to form the income, and the negative values are summed to form the deduction.
- The taxable income is computed as the income less the deduction, except in the case that the deduction is greater than than the income in which case the taxable income is zero.
- A tax group is calculated from the taxable income:
- Greater or equal to $500000 = Stinking rich
- Greater or equal to $200000 = Quite rich
- Greater or equal to $100000 = Miami poor
- Greater or equal to $50000 = Average
- Greater or equal to $20000 = Realistic
- Less than $20000 = Poor
- The tax is computed using one of three rates:
- The stinking rich and quite rich get taxed at the high rate of 25%.
- The Miami poor get taxed at the medium rate of 10%.
- The average and realistic get taxed at the low rate of 3%.
- The poor pay no tax.
- The tax information is displayed.
Here what a sample run should look like (with the keyboard input shown in italics) ...
Enter next amount : 125000
Enter next amount : -250
Enter next amount : -3000
Enter next amount : 15000
Enter next amount : 88000
Enter next amount : -200
Enter next amount : 0 Income = $228000.0
Deductions = $3450.0
Taxable income = $224550.0
Tax group = Q
Tax owed = $56137.5
Luckily, someone has already done the analysis and design, resulting in the following structure chart and algorithm ...
1. Input income and deduction
1.1 Repeatedly until 0.0 is entered
1.1.1 Prompt user
1.1.2 Input value
1.1.3 If positive
1.1.3.1 Add to income
1.1.4 If negative
1.1.4.1 Add (absolute) to deduction
2. Compute taxable income
2.1 If income >= deduction then taxable is income - deduction, else
2.2 Taxable is 0.0 3. Compute tax group
3.1 If taxable >= 500000
3.1.1 Group is S, else
3.2 If taxable >= 200000
3.2.1 Group is Q, else
3.3 If taxable >= 100000
3.3.1 Group is M, else
3.4 If taxable >= 50000
3.4.1 Group is A, else
3.5 If taxable >= 20000
3.5.1 Group is R, else
3.6 Group is P 4. Compute tax
4.1 Depending on the group
4.1.1 For S and Q
4.1.1.1 Tax is 25% of taxable
4.1.2 For M
4.1.2.1 Tax is 10% of taxable
4.1.3 For A and R
4.1.3.1 Tax is 3% of taxable
4.1.4 For P
4.1.4.1 Tax is 0.0
4.1.5 For other groups
4.1.5.1 Error!
5. Display tax information
5.1 Display income
5.2 Display deduction
5.3 Display taxable
5.4 Display group
5.5 Display tax
- Implement the program in Java. Internal nodes of the structure chart must be implemented as separate methods. The implementation must follow the design.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started