Solved

Math and Percentages

Posted on 2013-01-25
46
249 Views
Last Modified: 2013-01-25
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
Fee to Buy Car: 10%

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.

Thanks for your help in advance.
0
Comment
Question by:JPERKS1985
  • 24
  • 17
  • 3
  • +1
46 Comments
 
LVL 7

Expert Comment

by:Element1910
Comment Utility
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
 
LVL 7

Expert Comment

by:Element1910
Comment Utility
Nevermind, that would just let you even out. Let me think about this one :P
0
 
LVL 1

Author Comment

by:JPERKS1985
Comment Utility
It seems easy at first then you go in loops!
0
 
LVL 26

Expert Comment

by:MidnightOne
Comment Utility
In part #2 - the dealer pays 15% of what, his cost or the final purchase price from the 3rd party seller?
0
 
LVL 26

Expert Comment

by:MidnightOne
Comment Utility
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
 
LVL 17
Comment Utility
I have you buying at 594
Add 10% gives 654
Add 15% gives 751
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
 
LVL 1

Author Comment

by:JPERKS1985
Comment Utility
I need to know how you figure out to  buy at 594
0
 
LVL 17
Comment Utility
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
 
LVL 17
Comment Utility
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
 
LVL 1

Author Comment

by:JPERKS1985
Comment Utility
Hmm, can't get it to work. Heres my code,

$buysuggest = ($averagerecentsell * .10 * .15 * .33) / 1;
$buysuggest = round($buysuggest * 100, 2);

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

Expert Comment

by:MidnightOne
Comment Utility
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);

Open in new window

may put it together. Perl?
0
 
LVL 1

Author Comment

by:JPERKS1985
Comment Utility
Its in PHP
0
 
LVL 17
Comment Utility
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
 
LVL 17
Comment Utility
Ah yes. the divide by 1 is a bit upside down.
Inverse is 1 / mysum  not mysum/1
0
 
LVL 1

Author Comment

by:JPERKS1985
Comment Utility
1 / ($averagerecentsell * 1.10 * 1.15 * 1.33)  = 0.01
0
 
LVL 17
Comment Utility
Not sure where the *100 is coming from.
I get
buy=sell*1/(1.1 * 1.15 * 1.33)
 which equates to sell*.594 or close

you dont want to multiply that by 100.
0
 
LVL 17
Comment Utility
1/100 = .01
 what is the value of your avcentsell?
0
 
LVL 17
Comment Utility
Ah I see. Move the sellvalue outside the inverse calculation.
Try the calc I offered above
0
 
LVL 1

Author Comment

by:JPERKS1985
Comment Utility
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
 
LVL 1

Author Comment

by:JPERKS1985
Comment Utility
$averagerecentsell = "83.58";

$buysuggest = $averagerecentsell*1/(1.1 * 1.33);

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
 
LVL 17
Comment Utility
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
 
LVL 17
Comment Utility
> buysuggest = $averagerecentsell*1/(1.1 * 1.33);

 doesn't include your 15%

if you want that separately the calc will change.
0
 
LVL 17
Comment Utility
Sorry I am cross-posting a lot. I am typing this on a phone and its not very fast.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 1

Author Comment

by:JPERKS1985
Comment Utility
Why do we use 1.33? We need 25% profit?
0
 
LVL 17
Comment Utility
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
 
LVL 17
Comment Utility
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
 
LVL 1

Author Comment

by:JPERKS1985
Comment Utility
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";
$buyfeepercent = ".10";

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

$buypricebeforefeestakenout = UNKNOWN;

($sellprice - ($sellprice * .$sellfeepercent)) - ($buypricebeforefeestakenout - ($buyfeepercent * $buypricebeforefeestakenout)) = $buypricebeforefeestakenout * 1.25
0
 
LVL 17
Comment Utility
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
 
LVL 17
Comment Utility
Oh this isn't easy on a mobile. sorry about the formatting.
0
 
LVL 17
Comment Utility
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%.
Have your requirements changed?
0
 
LVL 1

Author Comment

by:JPERKS1985
Comment Utility
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
 
LVL 17
Comment Utility
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
 
LVL 1

Author Comment

by:JPERKS1985
Comment Utility
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
Cost Before Buy Fee: 618.22
Sell Payout: 850
Percent Profit: 1.24992279889%

Total Buy Price with 10%: 680.042
Cost Before Buy Fee: 618.21
Sell Payout: 850
Percent Profit: 1.2499430173%

Total Buy Price with 10%: 680.031
Cost Before Buy Fee: 618.2
Sell Payout: 850
Percent Profit: 1.24996323637%

Total Buy Price with 10%: 680.02
Cost Before Buy Fee: 618.19
Sell Payout: 850
Percent Profit: 1.2499834561%

Total Buy Price with 10%: 680.009
Cost Before Buy Fee: 618.18
Sell Payout: 850
Percent Profit: 1.25000367648%



<?
$sellprice = "1000";
$buyfeepercent = ".10";

$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;

}


?>

Open in new window

0
 
LVL 1

Author Comment

by:JPERKS1985
Comment Utility
The value we want to end up with is Cost Before Buy Fee
0
 
LVL 17
Comment Utility
I have a result.
Buy at 481.82
Add 10% (48.18) giving 530.00
Sell at 1000 and pay your 15% fee if 150.
Your costs are now 680.00
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
 
LVL 1

Author Comment

by:JPERKS1985
Comment Utility
I don't think buying at 481.82 makes sense.
0
 
LVL 17
Comment Utility
Did you follow my calculations?
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
 
LVL 1

Author Comment

by:JPERKS1985
Comment Utility
You need to get a result of 618.18.
0
 
LVL 17
Comment Utility
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)
Buy price with those figures=618.18
0
 
LVL 17

Accepted Solution

by:
Thibault St john Cholmondeley-ffeatherstonehaugh the 2nd earned 500 total points
Comment Utility
Yay!

Formula is:

(buy * 1.1) * 1.25 = 850
 so buy *  1.375 = 850
850/1.375=618.18 = buy price.
0
 
LVL 17
Comment Utility
Sorry it took so long to understand the requirements.
0
 
LVL 1

Author Comment

by:JPERKS1985
Comment Utility
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);

Open in new window

0
 
LVL 1

Author Closing Comment

by:JPERKS1985
Comment Utility
Thanks!
0
 
LVL 17
Comment Utility
Thanks

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

Author Comment

by:JPERKS1985
Comment Utility
Why do we use the 1.375 again? sorry
0
 
LVL 17
Comment Utility
Its the 1.1 multiplied by the 1.25
The cost+buyfee added to 25% of itself to get your 25% profit.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Solving an equation 8 60
CAGR Calculation For SIP 13 60
Need a nodal sequencing tool 3 44
Triangles - computing angles 7 38
Foreword (May 2015) This web page has appeared at Google.  It's definitely worth considering! https://www.google.com/about/careers/students/guide-to-technical-development.html How to Know You are Making a Difference at EE In August, 2013, one …
Have you ever thought of installing a power system that generates solar electricity to power your house? Some may say yes, while others may tell me no. But have you noticed that people around you are now considering installing such systems in their …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now