Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this init data:

- the total price includes the tax (totalPrice) = x
- the Tax Percent % (taxPercent) = p

how to calculate the value of the tax.

What I have tried:

i can calculate the total value using the tax percent. but i don't have any idea to do the reverse.
Posted
Updated 12-Mar-22 4:01am

1 solution

Total = valueWithoutTax * (1 + TaxPercentage / 100)
t = x * (1 + p / 100)
So if x = 50 and p = 25% then:
t = 50 * (1 + 25 / 100)
t = 50 * (1 + 0.25)
t = 50 * 1.25
t = 62.5

Therefore:
x = t / (1 + p / 100)

So if the total t is 62.5 and the tax percentage is 25 then:
x = 62.5 / ( 1 + 25 / 100)
x = 62.5 / ( 1 + 0.25)
x = 62.5 / 1.25
x = 50
And the value of the tax is the difference between the total including tax (62.5) and the total excluding tax (50) == 12.5

That's all basic maths you are taught at what? Age 11? Younger?
 
Share this answer
 

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