# Simple math calcuation / algorithm

I need a rather simple math/calculation algorithm (at least for someone who is good with this kind of thing)

It would be great if it could be done as a function in Delphi, but as long as I can convert it from another programming language (C,C++,VB) that's fine.

There will be a few different numbers inputted to it & I need a single value returned.

To be more specific, it's to make a buying decision on a product based on the inputs.

Those inputs would be:

- An average buy price for the product

- The last known (but possibly not accurate) "lowest" buy price for the item

- A "risk" level (very low to very high, see details)

I basically need it to output a price based on those 3 things that would be a good/safe price to make a profit.

## Deliverables

I'm imagining a function like

type

TRiskLevel = (riskVeryLow = 0, riskLow = 1, riskMediumLow = 2, riskMedium = 3, riskMediumHigh = 4, riskHigh = 5, riskVeryHigh = 6);

function GetBuyPrice(AverageMP: Integer; LowestMP: Integer; RiskLevel: TRiskLevel);

begin

Result := {your algorithm / code};

end;

It should also take in account for "inflation" of the item. Say if the lowestMP is greater than the AverageMP, it should be more careful and maybe base the result more on the AverageMP than the Lowest.

It can use a combination of the 2 though.

Some examples of the kind of results I want to see:

(10,000 average, 9,000 lowest with varying risk levels)

(30,000 average, 32,000 lowest with varying risk levels)

GetBuyPrice (30000, 32000, riskMedium) -> 15,000

(100,000 avg, 150,000 lowest (inflated) with varying risk levels)

GetBuyPrice(100000, 150000, riskVeryLow) -> 125,000 (since it's very low, it goes over the average in this case)

(500,000 avg, 475,000 lowest)

(3,000,000 avg, 3,500,000 lowest)

I'm not really sure how to explain it exactly, so I hope this makes some sense. It has to vary based on how high/low the price is (there's generally more of a gap when the price is higher, and a smaller one when it's a low priced item)

I basically want it to be enough to always make a profit and it has to guess when it's a good idea to buy (using the result of this function and the risk levels provided by me)

Example of the profit for items (in a medium-low risk)

an item at 25,000 should have a profit of at least 5,000

for items priced at 50,000 it should ideally be 10,000-12,500

100,000 should be about 20-35k profit

150,000 should be 30-45k

300,000 should be 50-60k or more profit

1,000,000 should be a profit of at least 125-150k

and so on

if it goes to huge numbers like

10,000,000, the profit should be at least a million on a low risk

50,000,000 should be at least 4-5 million on a medium risk

etc.

I don't know what else to say other than give examples. I hope someone will understand what I need.

**I don't want a ton of 'if' statements, some are OK but I would prefer it to be some kind of advanced math calculation

** Feel free to ask me questions.

Thanks a lot.

( 23 comentários ) United States

ID do Projeto: #2991204

## 24 freelancers are bidding on average \$76 for this job

quickprogexpert

See private message.

\$55.25 USD in 2 dias
(126 Comentários)
6.2
mentorvisionpak

See private message.

\$42.5 USD in 2 dias
(34 Comentários)
6.0
jal540

See private message.

\$102 USD in 2 dias
(39 Comentários)
5.6
VedAlek

See private message.

\$51 USD in 2 dias
(53 Comentários)
5.3
larzul

See private message.

\$25.5 USD in 2 dias
(33 Comentários)
4.4
billyhandiii

See private message.

\$17 USD in 2 dias
(24 Comentários)
4.2
brianchirgwin

See private message.

\$255 USD in 2 dias
(7 Comentários)
3.3
Ruel

See private message.

\$17 USD in 2 dias
(11 Comentários)
3.0
limelect

See private message.

\$297.5 USD in 2 dias
(1 Comentário)
2.8
hemn559

See private message.

\$68 USD in 2 dias
(3 Comentários)
2.7
homi12345

See private message.

\$8.5 USD in 2 dias
(9 Comentários)
2.7

See private message.

\$8.5 USD in 2 dias
(4 Comentários)
2.6
jack0stone

See private message.

\$34 USD in 2 dias
(9 Comentários)
2.6
HITESHGOYAL0803

See private message.

\$21.25 USD in 2 dias
(7 Comentários)
2.2
govega

See private message.

\$170 USD in 2 dias
(3 Comentários)
1.9
webdevelopor

See private message.

\$85 USD in 2 dias
(2 Comentários)
1.6
shivazmailboxeu

See private message.

\$10.2 USD in 2 dias
(5 Comentários)
0.7
simplypv

See private message.

\$34 USD in 2 dias
(0 Comentários)
0.0
hemantgoindani

See private message.

\$255 USD in 2 dias
(0 Comentários)
0.0
softwarepat

See private message.

\$85 USD in 2 dias
(7 Comentários)
0.0