• Status: Solved
• Priority: Medium
• Security: Public
• Views: 265

# Math and Percentages

I'm writing some PHP software to calculate prices. I'm having trouble wrapping my head around something. I'll put it in terms of cars to simplify what I'm looking for.

Average Cost of Car: \$1000

Cost To Sell Car: 15%
Profit Needed: 25%

The software I'm building suggests prices to buy cars at based on the average sale price of the car. Here is how it works,

Car dealer buys car, pays extra 10% in a fee to buy
Car dealer pays 15% to 3rd party to market car
Car dealer wants to make at least 25% on the car.

I need to come up with some sort of equation of what to buy the car (before the buy fee) at knowing they are going to charge me an extra 10% to buy the car and then sell the car at the average market price minus the 15% fee it will cost me to sell the car. On top of it the price we pay for the car must leave 25% profit to be made. This gets tricky as the price we pay directly influences the buy fee. Of course what we buy the car for will be well below the average sell price of \$1000 as we want to make money. Also keep in mind that we will assume we are going to be able to sell the car for \$1000 not more or less.

0
JPERKS1985
• 24
• 17
• 3
• +1
1 Solution

Commented:
You should just be able to do:

Avg Cost - 25% = Car Dealer Cost

This takes into account both 10% and 15% fees and leaves 25% profit.
0

Commented:
0

Author Commented:
It seems easy at first then you go in loops!
0

Commented:
In part #2 - the dealer pays 15% of what, his cost or the final purchase price from the 3rd party seller?
0

Commented:
If my previous question is answered "The 15% fee is based on the 3rd party selling price" the answer is this: (Buy cost) * 1.58125 = (sell price from 3rd party).
0

Commented:
I have you buying at 594
And sale price of 1000 allowing 249 to take as profit.
All other values were outgoing costs totalling 751. So you are taking about 25% of the sale price. If you want 25% of the cost then buy at 632.

All figures approx and ignoring pennies.
0

Author Commented:
I need to know how you figure out to  buy at 594
0

Commented:
I actually used goal seek in excel but the calculation is as I showed. You could simplify this easily by using the result which is 1000 so you buy at 59.4% of your final sale price. If you want the full calculation just multiply the percentages so it's 1.10 x 1.15 x 1.33 The 1.33 is because you are taking .33 for profit and leaving 3x.33 as the costs so you are taking 25% of the sale.
0

Commented:
I missed a bit. If you multiply out those percentages you get 1.68245 which represents the total increase on the buy price. Get the inverse of this to find the buy price from the sale price. So 1/1.68245 which gives .594.
I hope that's clear enough.
0

Author Commented:
Hmm, can't get it to work. Heres my code,

\$buysuggest = (\$averagerecentsell * .10 * .15 * .33) / 1;

Should be easy enough to understand even if you don't do any programming.
0

Commented:
Well dividing by one doesn't get you anything but what you started with.
``````\$buysuggest = round((\$averagerecentsell * 1.10 * 1.15 * 1.33)*100,2);
``````
may put it together. Perl?
0

Author Commented:
Its in PHP
0

Commented:
You are multiplying  .1 .15 and .33.

It should be 1.1 1.15 and 1.33
You want to find the whole 110% etc of the price,  not just the 10% figure.
It's the same as finding the price plus 10% of the price but shorter .
0

Commented:
Ah yes. the divide by 1 is a bit upside down.
Inverse is 1 / mysum  not mysum/1
0

Author Commented:
1 / (\$averagerecentsell * 1.10 * 1.15 * 1.33)  = 0.01
0

Commented:
Not sure where the *100 is coming from.
I get
which equates to sell*.594 or close

you dont want to multiply that by 100.
0

Commented:
1/100 = .01
what is the value of your avcentsell?
0

Commented:
Ah I see. Move the sellvalue outside the inverse calculation.
Try the calc I offered above
0

Author Commented:
Average Sale Price: \$98.33 - \$14.75 = \$83.58

\$83.58 is the avcentsell value. Note that the \$14.75 is showing the 15% sell fee.
0

Author Commented:
\$averagerecentsell = "83.58";

produces

67.2134882661

If we buy at 67.21 + 10% = 73.931
then sell the at 83.58 (after 15% in fees) we make \$9.649 which is less than 25% of 73.931
0

Commented:
You are losing me a bit now.
You started by saying you wanted a final sale price of 1000.
You wanted to take 25% of that for profit. leaving 750.
It is the 750 that contains the 15% sale fee.

Once you have a calc with a sale price of 1000 generating a buy of 594 then try with different values.
0

Commented:
> buysuggest = \$averagerecentsell*1/(1.1 * 1.33);

if you want that separately the calc will change.
0

Commented:
Sorry I am cross-posting a lot. I am typing this on a phone and its not very fast.
0

Author Commented:
Why do we use 1.33? We need 25% profit?
0

Commented:
Take 1.33 and divide it into 4
Take one quarter and it leaves 3x.33
You have taken 25%.

If you use 1.25 and take .25 you have only taken a fifth or 20%.

I tried to explain that in my second post.
0

Commented:
Sorry thats not clear.
Its the reverse of adding a percentage on.
So if you want 25% of the whole but you only know the value that is left afterwards the remaining value must be 75% of the full figure (1000)
75% divides neatly into 3  so divide you need 4/3 of that price to find the full value you want the 25% of.

Is that better?
0

Author Commented:
Still can't get it to work, I don't think I'm explaining myself well enough. Here is an equation that I think should equal out with one unknown.

\$sellprice = "1000";

\$sellfeepercent = ".15";
\$profitdesired = ".25";

0

Commented:
You are still missing the Whole values. You need( sellp x sellpercent + sellp) What you are doing is just taking the percentage and not including the whole. For instance say you want to know the cost price plus the 25% profit you take the price and add it to the cost x .25. Your sum is just cost x .25 which simply finds a quarter if the cost. What you should multiply by is 1.25 which will find the sale price, not just the markup.
0

Commented:
Oh this isn't easy on a mobile. sorry about the formatting.
0

Commented:
Your last code has me lost. what are you actually trying to do?

Initially you stated three percentages that needed to be removed from the final sale price of 1000 (no more no less) and wanted a way to calculate the initial price.
Now you seem to be trying to find the sale price and adding a further 25%.
0

Author Commented:
We need to know the list price to buy at knowing once we buy at that price an additional 10% will be tacked on. Then when I go to sell at the average price of \$1000 I will lose \$150 off the top in a 15% sell fee. The list price we choose to buy at we will want to make 25% on once the sale is complete.

For instance if we buy at \$100 list price it comes out to us buying it at \$110 after the buy fee.
We need to replace the \$100 with the highest number we can buy at and still make 25% after paying listprice + 10% of listprice and then listing at \$1000 and subtracting 15% sell fee.

After selling at average price we take in: \$850 (after 15% subtracted)
So now we have to figure out what listprice is so that

\$850 - (list price + 10%) = -25% or a 25% profit after fees.
0

Commented:
I think i'm getting it now. The 15% is from the final sale price.
The 10% is added to the cost price.
And adding those two amounts to the cist price gives your total costs.
You wush to make 25% of this total cost as a profit.
If that is correct then the calc is slightly different as I was adding the 15% before the profit was taken out and assuming you wanted profit calculated on the final sale.
I'll come back with a new calc.
0

Author Commented:
This gross looking code figures it out. It stops when it finds the correct value. Here is the last bit of output, the last output is the correct number.

Total Buy Price with 10%: 680.053
Sell Payout: 850
Percent Profit: 1.24992279889%

Total Buy Price with 10%: 680.042
Sell Payout: 850
Percent Profit: 1.2499430173%

Total Buy Price with 10%: 680.031
Sell Payout: 850
Percent Profit: 1.24996323637%

Total Buy Price with 10%: 680.02
Sell Payout: 850
Percent Profit: 1.2499834561%

Total Buy Price with 10%: 680.009
Sell Payout: 850
Percent Profit: 1.25000367648%

``````<?
\$sellprice = "1000";

\$sellfeepercent = ".15";
\$profitdesired = ".25";

\$complete = 0;
\$X = 1000;

while(\$percentprofit<=1.25){
\$costafterfees = \$X + (\$X * \$buyfeepercent);
\$sellpayout = \$sellprice - (\$sellprice * \$sellfeepercent);

\$percentprofit = (1 / (\$costafterfees / \$sellpayout));

echo("Cost Before Buy Fee: ".\$X."<BR>Sell Payout: ".\$sellpayout."<BR>Percent Profit: ".\$percentprofit."%<BR><BR>");
echo("Total Buy Price with 10%: ".(\$X * 1.1)."<BR>");

\$X = \$X - .01;

}

?>
``````
0

Author Commented:
The value we want to end up with is Cost Before Buy Fee
0

Commented:
I have a result.
Sell at 1000 and pay your 15% fee if 150.
You have 850 coming in so leaving 170 profit which is 25% of the 680 costs.

There is a formula if these figures work for you I'll post it.
0

Author Commented:
I don't think buying at 481.82 makes sense.
0

Commented:
I'm adding 10% to the actual cost price and calling that a cost.
The 15% of the funal sale never changes. The sale price is always 1000 so 15% is 150.
I am also calling this a cost (perhaps it shouldn't be?)
Adding the 150 and the 530 costs give 680 total cost.
25% of the 680 cost is 170 (Your profit)
170+680+150= 1000, the final sale price.
Is this what you wanted?
0

Author Commented:
You need to get a result of 618.18.
0

Commented:
Hmm, can I try that again.
This time I'm buying at 618.18
Add a fee of 10% or 61.82 so costs are now 680 (without the sale fee).
25% of 680 is 170 si take your profit.
680 + 170 gives 850.
Sell at 1000 and subtract 150 for the 15% sale fee.
It adds up for me :7)
0

Commented:
Yay!

Formula is:

(buy * 1.1) * 1.25 = 850
so buy *  1.375 = 850
0

Commented:
Sorry it took so long to understand the requirements.
0

Author Commented:
Thank you for your patience, attached is final code if your interested.

``````\$sellprice = "1000";
\$sellfee = ".15";

\$netsellprice = \$sellprice - (\$sellprice * \$sellfee);
\$output = \$netsellprice/1.375;
echo(\$output);
``````
0

Author Commented:
Thanks!
0

Commented:
Thanks

Remember where that 1.375 comes from in case you ever need to change one of the percentages.
0

Author Commented:
Why do we use the 1.375 again? sorry
0

Commented:
Its the 1.1 multiplied by the 1.25
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.