I’m not sure if the said algorithm is the actual code, or simply a representation of it. Were it to be the actual code, and just on an anecdotic tone, with my current Activity (1414) the algorithm would do:
waittime = 360;
if(1414 >= 15) --> True
waittime = (int)(90 - 1414); --> -1324 !
if(1414 >= 60) --> True
waittime=(int)(34.7586 - (0.0793103 * 1414)); --> -77,3862 !
if(1414 >= 100) --> True
waittime = max((int)(14-(1414/50)), 4); --> 4 due to the max function
The more efficient thing to do would be to use
elseif or
case type structures. The resulting waittime variable content would be the same, but the algorithm, as is, will evaluate each if statement and calculate multiple waittimes which will be overwritten, whilst not being necessary.