I’m trying to make a small calculator, as a personal project. I have a little example here, what I want:
The user(me) get paid 10$ from a customer. What I do, is first to subtract the percentage which is 2.75% so after the subtraction I will have 9.725$ back. Then I take 1.5$ in fee. So I will be down on 8.225$ in the end.
That one works as it should.
What I then want to calculate is.
If I want 10$ AFTER fees are paid, (the 2.75% and 1.5$), how much should the customer then pay? and how could I do the calculation, so I could use any amount of moneys I want to receive.
Hope any can solve this ‘easy’ math problem.
A little bonus I would like to do also, is, if I edit the percentage to 3% etc, it should work too. (If impossible, then never mind).
I’m feeling really lost here at the moment!
Here are what I currently do, but it just adds 2.75% and the 1.5$ to the amount I specified.
function retPercent($amount, $percent)
{
return $amount + ($amount / 100 * $percent);
}
The problem here, is that I still don’t know how to calculate the percentage I actually should use (based on the 2.75%) that I get from the substraction.
Thank you a lot guys and girls!
Or more generally:
Other way round:
Example Use: