I'm not sure what what to call what I would like help creating so please bear with me.
Basically I have a program which assigns you a number of points(a competition point not a point on a graph or anything) depending on how quickly you answer a query. This is how it looks:
Response Time in Hours | Points Awarded
0 | 10 Points
1-6 | 8 Points
6-12 | 6 Points
12-18 | 4 Points
18-24 | 2 Points
24+ | 0 Points
This can be achieved by making multiple if queries but that could end up being a strain on the server. I would like to know if there is a formula that I could just multiply the response time by which could give me a result in that range? Is this even possible?
Thanks in advance for any help.
6 if-clauses are not really a "strain" on the server. In the code you shold stay at the if's; not sure if the evaluation of given $f$ might even be slower (multiply + subrtract + ceil(double) > 6 if ??)
Code:
if (t<1) return 10;
else if (t<6) return 8;
else if (t<12) return 6;
else if (t<18) return 4;
else if (t<24) return 2;
else return 0;
(sorry for the bad formatting, it's due to comments) – AlexR Aug 07 '13 at 10:13