Results 1 to 19 of 19
  1. #1
    Jamesing is offline Member
    Join Date
    Feb 2011
    Posts
    16
    Rep Power
    0

    Default I need a little help

    Hi, I'm making a program that will calculate tax deductions for certain salaries and I need help on part of it. I need to know how to do this to a single value:

    9.1% off the first $37,149 , +
    12.1% off the next $36,422, +
    12.4% off the next $46,496, +
    12.7% off the amount over $120,796

    However, sometimes the value may not be 120796 or greater, obviously, so I want to make it so, it will execute it accordingly. Thanks.

  2. #2
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    Have you made an attempt? If so, post what is not working for you, with relevant code.

  3. #3
    Jamesing is offline Member
    Join Date
    Feb 2011
    Posts
    16
    Rep Power
    0

    Default

    Quote Originally Posted by al_Marshy_1981 View Post
    Have you made an attempt? If so, post what is not working for you, with relevant code.
    I have not yet made an attempt, because I have no idea how to put it, syntactically.

  4. #4
    Jamesing is offline Member
    Join Date
    Feb 2011
    Posts
    16
    Rep Power
    0

    Default

    Quote Originally Posted by Notsopro View Post
    I've got an idea give up on java and learn C++.
    Shouldn't you be in a C++ forum?

  5. #5
    Jamesing is offline Member
    Join Date
    Feb 2011
    Posts
    16
    Rep Power
    0

    Default

    Quote Originally Posted by Notsopro View Post
    Shouldn't you be dead?
    No, I don't think so.

  6. #6
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    lol, whats with the angry c++ fanboi?

    Show your code and let us see what you have so far please.

  7. #7
    Jamesing is offline Member
    Join Date
    Feb 2011
    Posts
    16
    Rep Power
    0

    Default

    Quote Originally Posted by sunde887 View Post
    lol, whats with the angry c++ fanboi?

    Show your code and let us see what you have so far please.
    I have already finished coding all the other sections I need.

    I haven't started coding this part yet, other than declaring the variables, so there is really nothing for me to post. I just need someone to help me get started.

  8. #8
    Jamesing is offline Member
    Join Date
    Feb 2011
    Posts
    16
    Rep Power
    0

    Default

    Java Code:
    double YPay_After_ProvTax, MPay_After_ProvTax, First_Line, Second_Line, Third_Line, Fourth_Line;
    There is all the vaariables
    Last edited by Jamesing; 02-21-2011 at 10:57 PM.

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  10. #10
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,762
    Rep Power
    7

    Default

    Quote Originally Posted by Jamesing View Post
    I have already finished coding all the other sections I need.

    I haven't started coding this part yet, other than declaring the variables, so there is really nothing for me to post. I just need someone to help me get started.
    Take out a piece of paper and work out how you would do this. For example how would you determine if a salary should have the 9.1% tax imposed? How would you determine if a salary should have the 12.1% tax imposed? etc

  11. #11
    Jamesing is offline Member
    Join Date
    Feb 2011
    Posts
    16
    Rep Power
    0

    Default

    Quote Originally Posted by Junky View Post
    Take out a piece of paper and work out how you would do this. For example how would you determine if a salary should have the 9.1% tax imposed? How would you determine if a salary should have the 12.1% tax imposed? etc
    Yes, I understand how to work out the math and apply this tax to a salary myself, but I don't know how I would tell a Java program to do this.

  12. #12
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,762
    Rep Power
    7

    Default

    So tell me, if I have a salary of $32,000 how much tax will you deduct and explain how you determined that.

  13. #13
    Jamesing is offline Member
    Join Date
    Feb 2011
    Posts
    16
    Rep Power
    0

    Default

    Quote Originally Posted by Junky View Post
    So tell me, if I have a salary of $32,000 how much tax will you deduct and explain how you determined that.
    32000 * .091 = 2912
    32000 - 2912 = 29088
    Your Salary, after provincial Tax would be $29088.
    You deduct $2912.

  14. #14
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    Use a series of if statements to determine wether the cash amount you wish to apply tax to falls within certain conditons e.g if cash less than or equal to 37149 then do appropiate calculation.
    Last edited by al_Marshy_1981; 02-22-2011 at 01:00 AM. Reason: appropiate did not contain a 'g' when I went to school

  15. #15
    Jamesing is offline Member
    Join Date
    Feb 2011
    Posts
    16
    Rep Power
    0

    Default

    Quote Originally Posted by al_Marshy_1981 View Post
    Use a series of if statements to determine wether the cash amount you wish to apply tax to falls within certain conditons e.g if cash less than or equal to 37149 then do appropiate calculation.
    Yeah, I know how to do that.
    Java Code:
    if (yearlypay <= 37149)
    yearlypay = (yearlypay * .091);
    But what if it is a value above 37149, like 40000, how would I tell it to times the first 37149 by .091 and tell it to times the next 2815 by .121?

  16. #16
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    Keep track of each deduction amount with a variable say called totalDeductions.

    Here is some semi real code to look at:
    Java Code:
    int totalDeductions=0;
    if(yearlyPay <= 37149){
         // calculate tax deduction and add it to totalDeductions current amount
        //  totalDeductions+=taxDeduction;
    }
    
    if(yearlyPay <= theNextAmount){
       // calculations tax deduction and add it to totalDeductions current amount
        
    }
    
    // etc if statements for the other amounts

  17. #17
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,762
    Rep Power
    7

    Default

    Quote Originally Posted by Jamesing View Post
    Yeah, I know how to do that.
    Java Code:
    if (yearlypay <= 37149)
    yearlypay = (yearlypay * .091);
    But what if it is a value above 37149, like 40000, how would I tell it to times the first 37149 by .091 and tell it to times the next 2815 by .121?
    Ever heard of subtraction? 37149 is taxed at 9.1%. 40000 - 37149 is taxed at 12.1%. It really isn't that hard.

  18. #18
    Jamesing is offline Member
    Join Date
    Feb 2011
    Posts
    16
    Rep Power
    0

    Default

    I'm not sure if that will work, but I will try it. You see, with this formula, there isn't really a next amount. It takes 9.1 percent off the first 37149, then 12.1 percent off the next 36422, so how do I account for the numbers in the middle. Do you think your code will do that? It doesn't look like it will to me, but I could be wrong.

  19. #19
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    Like Junky has pointed out working out the numbers in the middle is a pretty easy task once you know the initial value is 37149 or whatever it was.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •