Results 1 to 11 of 11
Thread: Help With Assignment
- 03-28-2011, 07:27 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 23
- Rep Power
- 0
Help With Finishing Assignment
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:
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:
Java 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); } }Last edited by EpyonCustom; 04-01-2011 at 11:15 PM.
-
whats wrong with the last line? calculation error? compiler error? what error?
- 03-28-2011, 07:38 PM #3
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
What exactly happens when you run the program? The code seems pretty good.
- 03-28-2011, 11:24 PM #4
Member
- Join Date
- Mar 2011
- Posts
- 23
- Rep Power
- 0
I'll have to get back to you on that. I use a Mac for personal use and do my programming on the school computers, which I won't have time to get to until Wednesday.
The grid that shows all the tax income ranges will print (although I still haven't formatted correctly. Everything is right next to each other). The program also asks the questions I wrote, but an error occurs once I try to get the results. And once again, I'll have to get back to you on what exactly that error is.
By the way, I'm also using a testing program which simply runs the calculateIncomeTax application.
- 04-01-2011, 11:10 PM #5
Member
- Join Date
- Mar 2011
- Posts
- 23
- Rep Power
- 0
UPDATE:
Here is the test program:
I'll provide the error message(s) tomorrow. But if you see anything fishy with either the main program or the test program, please let me know.Java Code:public class IncomeTaxTester { public static void main( String args[] ) { IncomeTax application = new IncomeTax(); application.calculateIncomeTax(); } }
- 04-01-2011, 11:13 PM #6
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Everything seems to look decent, however, I'm too lazy to compile it(also can't atm), the error messages will allow me to (hopefully) find your problem.
- 04-01-2011, 11:18 PM #7
Member
- Join Date
- Mar 2011
- Posts
- 23
- Rep Power
- 0
If you, or someone else, could compile it for me, that would be awesome. The computer lab at my school closes early on Fridays, which I was not aware of, so I can't compile this until tomorrow.
Also, I removed the commas within the numbers of the main program. So you should be able to just paste both programs, compile them, and see what's wrong.
-
If you have a computer you can download the JDK and you can compile it. If you can't compile then let's agree to put this question on hold until you can since our help won't be useful to you until then.
- 04-03-2011, 03:35 AM #9
Hi,
I compiled your code and I got this error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Syntax error on token ",", delete this token
at IncomeTax.calculateIncomeTax(IncomeTax.java:82)
at IncomeTaxTester.main(IncomeTaxTester.java:6)
- 04-03-2011, 05:36 AM #10
Member
- Join Date
- Mar 2011
- Posts
- 23
- Rep Power
- 0
- 04-03-2011, 06:04 AM #11
Hi,
Heres how to read errors in a compiler:
(IncomeTax.java:82) > means the error is on your IncomeTax class at line 82.at IncomeTax.calculateIncomeTax(IncomeTax.java:82)
at IncomeTaxTester.main(IncomeTaxTester.java:6)
Try to figure out what is your error on line 82.
What IDE are you using?
With regards to JDK on MAC OS here's what I found out: Java and the Mac OS X
Similar Threads
-
Need Help With Assignment
By zeo in forum New To JavaReplies: 10Last Post: 02-25-2011, 12:09 AM -
Need with my assignment ...
By allergy01 in forum New To JavaReplies: 1Last Post: 04-25-2009, 08:33 AM -
Can somebody help me in my assignment
By coolstruxx in forum NetBeansReplies: 0Last Post: 03-24-2009, 01:27 AM -
I am looking for help with an assignment
By nanoo51969 in forum New To JavaReplies: 1Last Post: 03-23-2009, 09:41 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks