# Thread: Formula for Calculating original quantities from a price

1. ## Formula for Calculating original quantities from a price

Hi I need a formula to solve the following problem, unfortunately my maths is pretty basic.

Item A = 0.23 per unit up to and including first 150 units
Item A = 0.18 per unit above 150 units
Item B = 0.15 per unit
Item A Quantity = 400 = (150 * 0.23) + (250 * 0.18) = 79.5
Item B Quantity = 400 * 0.15 = 60.0
----
Total Price = 139.5
----

Now if we have the Total Price, the percentage of the quantity of Item B and the above per unit rates
how do you calculate what quantity of each item was brought originally.
It should be possible to get back to Item A Quantity 400 and Item B Quantity 400 given

Total Price = 139.5
Percentage of quantity of Item B = 50%
Item A = 0.23 per unit up to and including first 150 units
Item A = 0.18 per unit above 150 units
Item B = 0.15 per unit

Please note that the percentage of quantity of item B is not constant

Thanks in advance for any help
Darren

2. Originally Posted by Unknown008
Hm, let's define variables.

Let x be the number of items A.
Let y be the number of items B.

We know that Price for A = 0.23n (for $n\leq 150$) + 0.18(x - n)
Price for B = 0.15y

Now, total gives:

0.23 n + 0.18(x-n) + 0.15y = 139.5

Second equation:
x = y

Substituting in first equation:

0.23n + 0.18(x - n) + 0.15x = 139.5

Assuming that there is less than 150 items of a, makes x - n = 0 and x = n
0.23x + 0 + 0.15x = 139.5
x = 367

But x should have been less than 150!

So, we know that x is greater than 150, so, n = 150

0.23(150) + 0.18(x - 150) + 0.15x = 139.5
34.5 + 0.18x - 27 + 0.15x = 139.5
0.33x = 132
x = 400

So, y = 400
Wasn't this what you were looking for?

In case the percentage of B is not the same as that of A, you'll have to change the second equation, that is:

x = y

Into the appropriate new percentage.

If it were for example 75% of B and 25 % of A, this becomes:

3x = y

(where x still represents the number of items A)