If I have a cost I need to apply to every 50,000 items I sell and a customer buys 75,000 items.
I find the number of times I need to apply the cost by rounding 75,000 up to 100,000 (the uppermost multiple of 50,000) and diving by 50,000 (= 2 times).
Any ideas?
2006-08-16
22:45:09
·
5 answers
·
asked by
?
2
in
Computers & Internet
➔ Programming & Design
Thanks Leon but I don't it's as complicated as I first thought.
e.g
int GetCostMultiplier(int costThreshold, int qtySold)
{
int costMultiplier = 1;
while (costThreshold < qtySold)
{
costThreshold = costThreshold + costThreshold;
i++; // same as: i = i + 1
}
return costMultiplier;
}
seems to work.
2006-08-16
23:44:36 ·
update #1
I mean:
costMultiplier++; // same as: costMultiplier = costMultiplier + costMultiplier
not i++;
(I renamed my variables for clarity)
2006-08-16
23:50:42 ·
update #2