Greetings,
I am trying to programatically calculate a quota over a given period of time.
example:
User A needs to refer 3 friends to a my site every 3 months, starting the day they register.
I already have:
- the day they registered (4 months ago)
- how many referrals they already have (4)
- months elapsed (4)
I am trying to calculate the required number of referrals on command. In pseudo code:
If ( numberOfReferralsUserHas isLessThan ( numberOfMonthsRegistered / 3 ) * ){
run some code ;
run some more code;
}
I "know" the answer, but I keep drawing blank as far as the best implementation that would catch errors, like the user over exceeding the quota. I would just like to see it work first maybe that would help 'clear the fog'.
many thanks
solution:
**floor(round down a float)
referrals_needed = 3;
If ( numberOfReferralsUserHas isLessThan ( floor( numberOfMonthsRegistered / referrals_needed ) * referrals_needed) ){
run some code ;
run some more code;
}


LinkBack URL
About LinkBacks