for example, I have 1 computer with a discount, the price of this computer is $ 450 with a 10% discount, I want to know the real price of it, I want to learn this both over 10% and as 10% money.
Computer 10% off Price = 450$
Computer $10 off Price = 490$
$net_total = 450;
$discount_value = 10; < percent or amount
$gross_price = ?;
CodePudding user response:
Well, let's solve the equations:
Computer 10% off Price = 450$
Computer $10 off Price = 490$
Which can be written as (let x
be the initial price of the computer)
x - x * 10 / 100 = 450 # initial price - x without 10 % from x - x * 10% / 100%
x - 10 = 490 # just 10$ off
Or
0.9 * x = 450
x = 500
Finally
x = 450 / 0.9 = 500
x = 500
So from both equations we have that the initial computer's price is 500$
Edit: in general case,
if $discount_value
stands for per cent (i.e. $discount_value = 10
means 10%
discount) then
$gross_price = $net_total * 100.0 / (100.0 - $discount_value)
if $discount_value
stands for money (i.e. $discount_value = 10
means 10$
discount), then
$gross_price = $net_total $discount_value