Question

I have read many topics on reputation but none of them fits my needs. I am implementing a Q & A site. Each post (question/answer) can be voted. Each user has a reputation score. Depending on user's reputation, the vote for each post caries more weight. However, I dont want to do an endless if else, for example

if (0 < user_reputation < 10) then post_vote += 1
if (10 < user_reputation < 20) then post_vote += 2
if (20 < user_reputation < 30) then post_vote += 3
if (30 < user_reputation < 40) then post_vote += 4
..........

Please, suggest a better way (a formula or so) to calculate the post's vote without using the above endless if/else. I'm using Java.

Was it helpful?

Solution

use post_vote += (int)(user_reputation/10);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top