Click here to Skip to main content
15,886,780 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Please can anyone help me with C# code to calculate tax income rates payable on chargeable income. Thanks in advance.
Posted
Updated 4-Apr-18 19:38pm
Comments
Uwakpeter 21-May-12 18:03pm    
Thanks, i will try see if i could use it.

1 solution

C#
private decimal CalculateTax(decimal income)
{
    //•10% on taxable income from $0 to $8,500, plus
    //•15% on taxable income over $8,500 to $34,500, plus
    //•25% on taxable income over $34,500 to $83,600, plus
    //•28% on taxable income over $83,600 to $174,400, plus
    //•33% on taxable income over $174,400 to $379,150, plus
    //•35% on taxable income over $379,150.
    decimal incomeTax = 0;
    CalculateTaxForBracket(379150.0m, .35m, ref incomeTax, ref income);
    CalculateTaxForBracket(174400.0m, .33m, ref incomeTax, ref income);
    CalculateTaxForBracket(83600.0m, .28m, ref incomeTax, ref income);
    CalculateTaxForBracket(34500.0m, .25m, ref incomeTax, ref income);
    CalculateTaxForBracket(8500.0m, .15m, ref incomeTax, ref income);
    CalculateTaxForBracket(0.0m, .10m, ref incomeTax, ref income);

    return incomeTax;
}

private void CalculateTaxForBracket(decimal taxBraketFloor, decimal taxRate, ref decimal calculatedTaxes, ref decimal remainingIncome)
{
    if (remainingIncome > taxBraketFloor)
    {
        calculatedTaxes = calculatedTaxes + (remainingIncome - taxBraketFloor) * taxRate;
        remainingIncome = taxBraketFloor;
    }
}
 
Share this answer
 
Comments
Uwakpeter 24-May-12 22:04pm    
Please can you still through more light on these, i am just a newbie, little explanation of the parameters could go a long way! Thanks in advance.
Clifford Nelson 24-May-12 23:56pm    
The commented area was what I found searching using BING. I just used what I found, and made it into an equation. Did I answer you question, you have not rated it or accepted the solution.
Uwakpeter 25-May-12 17:50pm    
What argument should i use for taxRate seeing that we can't accept from user, i.e. taxRate is already known, and it has different values ranging from minimum to maximum.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900