I made a thread on Wednesday asking for immediate help, since my assignment was due in an hour. I received some help, but I wasn't able to completely correct everything before I had to turn in the assignment.
However, we have been given an extension on the assignment, since many students had trouble. So, can you guys please help me correct this last issue? There seems to be an error with the last line of code, however I can't tell you exactly what that error is until this Wednesday, since I don't have access to the school computers until then.
So until Wednesday, it would be very helpful if you could at least throw out some pieces of advice from what you see.
Here is the assignment:
Quote:
Income brackets and tax rates
An individual's marginal income tax bracket depends upon their income and their tax-filing classification.There are six tax brackets for ordinary income (ranging from 10% to 35%) and four classifications: single, married filing jointly (or qualified widow or widower), married filing separately, and head of household.
Marginal Tax Rate
Single Married Filing Jointly or Qualified Widow(er) Married Filing Separately Head of Household
10%
$0 – $7,825 $0 – $15,650 $0 – $7,825 $0 – $11,200
15%
$7,826 – $31,850 $15,651 – $63,700 $7,826 – $31,850 $11,201 – $42,650
25%
$31,851 – $77,100 $63,701 – $128,500 $31,851 – $64,250 $42,651 – $110,100
28%
$77,101 – $160,850 $128,501 – $195,850 $64,251 – $97,925 $110,101 – $178,350
33%
$160,851 – $349,700 $195,851 – $349,700 $97,926 – $174,850 $178,351 – $349,700
35%
$349,701+ $349,701+ $174,851+ $349,701+
An individual pays tax at a given bracket only for each dollar within that bracket's range. For example, a single taxpayer who earned $10,000 in 2007 would be taxed 10% of each dollar earned from the 1st dollar to the 7,825th dollar (10% × $7,825 = $782.50), then 15% of each dollar earned from the 7,826th dollar to the 10,000th dollar (15% × $2,175 = $326.25), for a total of $1,108.75. Notice this amount ($1,108.75) is lower than if the individual had been taxed at 15% on the full $10,000 (for a tax of $1,500). This is because the individual's marginal rate (the percentage tax on the last dollar earned, here 15%) has no effect on the income taxed at a lower bracket (here the first $7,825 of income taxed at 10%). This ensures that every rise in a person's pre-tax salary results in an increase of their after-tax salary, contrary to the popular misconception that being bumped into a higher tax bracket reduces after-tax income.
Here is the code:
Code:import java.util.Scanner;
public class IncomeTax
{
public void calculateIncomeTax()
{
Scanner input = new Scanner( System.in );
int classification;
int taxAmount;
double result;
System.out.printf( "%17s%7s%41s%25s%17s\n",
"Marginal Tax Rate", "Single", "Married Filing Jointly Or Qualified Widow",
"Married Filing Separately", "Head Of Household" );
System.out.printf( "%3s%11s%12s%11s%12s\n",
"10%", "$0 - $7,825", "$0 - $15,650",
"$0 - $7,825", "$0 - $11,200" );
System.out.printf( "%3s%17s%18s%17s%17s\n",
"15%", "$7,826 - $31,850", "$15,651 - $63,700",
"$7,826 - $31,850", "$11,201 - $42,650" );
System.out.printf( "%3s%17s%18s%17s%18s\n",
"25%", "$31,851 - $77,100", "$63,701 - $128,500",
"$31,851 - $64,250", "$42,651 - $110,100" );
System.out.printf( "%3s%18s%19s%17s%19s\n",
"28%", "$77,101 - $160,850", "$128,501 - $195,850",
"$64,251 - $97,925", "$110,101 - $178,350" );
System.out.printf( "%3s%19s%19s%18s%19s\n",
"33%", "$160,851 - $349,700", "$195,851 - $349,700",
"$97,926 - $174,850", "$178,351 - $349,700" );
System.out.printf( "%3s%9s%9s%9s%9s\n\n\n",
"35%", "$349,701+", "$349,701+",
"$174,851+", "$349,701+" );
System.out.print( "Enter Classification: " );
System.out.print( "1 = Single" );
System.out.print( "2 = Married Filing Jointly Or Qualified Widow" );
System.out.print( "3 = Married Filing Separately" );
System.out.print( "4 = Head Of Household" );
classification = input.nextInt();
System.out.print( "Enter income tax amount: " );
taxAmount = input.nextInt();
if ( classification == 1 )
{
if (taxAmount <= 7825) {
result = (.10 * taxAmount); }
else if (taxAmount >= 7826 && taxAmount <= 31850) {
result = (.10 * 7825) + (.15 * (taxAmount - 7825)); }
else if (taxAmount >= 31851 && taxAmount <= 77100) {
result = (.10 * 7825) + (.15 * (31850 - 7825)) + (.25 * (taxAmount - 31850)); }
else if (taxAmount >= 77101 && taxAmount <= 160850) {
result = (.10 * 7825) + (.15 * (31850 - 7825)) + (.25 * (77100 - 31850)) + (.28 * (taxAmount - 77100)); }
else if (taxAmount >= 160851 && taxAmount <= 349700) {
result = (.10 * 7825) + (.15 * (31850 - 7825)) + (.25 * (77100 - 31850)) + (.28 * (160850 - 77100)) + (.33 * (taxAmount - 160850)); }
else if (taxAmount >= 349701) {
result = (.10 * 7825) + (.15 * (31850 - 7825)) + (.25 * (77100 - 31850)) + (.28 * (160850 - 77100)) + (.33 * (349700 - 160850)) + (.35 * (taxAmount - 349700)); }
}
if ( classification == 2 )
{
if (taxAmount <= 15650) {
result = .10 * taxAmount; }
else if (taxAmount >= 15651 && taxAmount <= 63700) {
result = (.10 * 15650) + (.15 * (taxAmount - 15650)); }
else if (taxAmount >= 63701 && taxAmount <= 128500) {
result = (.10 * 15650) + (.15 * (63700 - 15650)) + (.25 * (taxAmount - 63700)); }
else if (taxAmount >= 128501 && taxAmount <= 195850) {
result = (.10 * 15650) + (.15 * (63700 - 15650)) + (.25 * (128500 - 63700)) + (.28 * (taxAmount - 128500)); }
else if (taxAmount >= 195851 && taxAmount <= 349700) {
result = (.10 * 15650) + (.15 * (63700 - 15650)) + (.25 * (128500 - 63700)) + (.28 * (195850 - 128500)) + (.33 * (taxAmount - 195850)); }
else if (taxAmount >= 349701) {
result = (.10 * 15650) + (.15 * (63700 - 15650)) + (.25 * (128500 - 63700)) + (.28 * (195850 - 128500)) + (.33 * (349700 - 195850)) + (.35 * (taxAmount - 349700)); }
}
if ( classification == 3 )
{
if (taxAmount <= 7825) {
result = .10 * taxAmount; }
else if (taxAmount >= 7826 && taxAmount <= 31850) {
result = (.10 * 7825) + (.15 * (taxAmount - ,825)); }
else if (taxAmount >= 31851 && taxAmount <= 64250) {
result = (.10 * 7825) + (.15 * (31850 - 7825)) + (.25 * (taxAmount - 31850)); }
else if (taxAmount >= 64251 && taxAmount <= 97925) {
result = (.10 * 7825) + (.15 * (31850 - 7825)) + (.25 * (64250 - 31850)) + (.28 * (taxAmount - 64250)); }
else if (taxAmount >= 97926 && taxAmount <= 174850) {
result = (.10 * 7825) + (.15 * (31850 - 7825)) + (.25 * (64250 - 31850)) + (.28 * (97925 - 64250)) + (.33 * (taxAmount - 97925)); }
else if (taxAmount >= 174851) {
result = (.10 * 7825) + (.15 * (31850 - 7825)) + (.25 * (64250 - 31850)) + (.28 * (97925 - 64250)) + (.33 * (174850 - 97925)) + (.35 * (taxAmount - 174850)); }
}
if ( classification == 4 )
{
if ( taxAmount <= 11200 ) {
result = (.10 * taxAmount); }
else if (taxAmount >= 11201 && taxAmount <= 42650) {
result = (.10 * 11200) + (.15 * (taxAmount - 11200)); }
else if (taxAmount >= 42651 && taxAmount <= 110100) {
result = (.10 * 11200) + (.15 * (42650 - 11200)) + (.25 * (taxAmount - 42650)); }
else if (taxAmount >= 110101 && taxAmount <= 178350) {
result = (.10 * 11200) + (.15 * (42650 - 11200)) + (.25 * (110100 - 42650)) + (.28 * (taxAmount - 110100)); }
else if (taxAmount >= 178351 && taxAmount <= 349700) {
result = (.10 * 11200) + (.15 * (42650 - 11200)) + (.25 * (110100 - 42650)) + (.28 * (178350 - 110100)) + (.33 * (taxAmount - 178350)); }
else if (taxAmount >= 349701) {
result = (.10 * 11200) + (.15 * (42650 - 11200)) + (.25 * (110100 - 42650)) + (.28 * (178350 - 110100)) + (.33 * (349700 - 178350)) + (.35 * (taxAmount - 349700)); }
}
System.out.println("Income tax amount is " + result);
}
}

