Re: wont get right output
For future reference use tags [code] Post code in side tags [/code]
System.out.println(); is a great way to check what is happening throughout your code. You can use it to check where your values are suppose to change and see if they are getting assigned correctly. Now you say your tax return is 0.00000 What inputs have you tried? Does it show for all of them or just for certain inputs? Also from how your code is it looks like it will show 2 "Invalid entry" when (1 > filingStatus > 4)
Re: wont get right output
Quote:
Originally Posted by
Ubiquitous
For future reference use tags [code] Post code in side tags [/code]
System.out.println(); is a great way to check what is happening throughout your code. You can use it to check where your values are suppose to change and see if they are getting assigned correctly. Now you say your tax return is 0.00000 What inputs have you tried? Does it show for all of them or just for certain inputs? Also from how your code is it looks like it will show 2 "Invalid entry" when (1 > filingStatus > 4)
Thank you for your reply......
I tried checking value using System.out.printf("%f",tax); and in all the place it shows 0.0000
I don't know what is the problem...This is my second time using switch statement.....I don't know if I can use multiple if else statement inside switch..........and also I tried with multiple values to check the tax......Every time it gives me 0.0000....... Is there any arithmetic error?
Re: wont get right output
You are doing Integer division as far as I can tell in all you tax calculations:
tax = tax+(33/100)*372950 + ((personalIncome-372950)*(35/100));
should look like this tax = tax+(33.0/100)*372950 + ((personalIncome-372950)*(35/100));
By adding the .0 you are wont lose all your extra data that integer division gets rid of.
I haven't checked if its returning the correct answer but that did clear up the problem of receiving 0 as a answer when I tested it
Re: wont get right output
Quote:
Originally Posted by
Avatar19
You are doing Integer division as far as I can tell in all you tax calculations:
tax = tax+(33/100)*372950 + ((personalIncome-372950)*(35/100));
should look like this tax = tax+(33.0/100)*372950 + ((personalIncome-372950)*(35/100));
By adding the .0 you are wont lose all your extra data that integer division gets rid of.
I haven't checked if its returning the correct answer but that did clear up the problem of receiving 0 as a answer when I tested it
Thank you very much......it worked once i added .00...........You are a life saver.....thank you very much once again
Re: wont get right output