How can i distribute prize to the winners in my game app?

I am making a knowledge based game , in which user participate and if they win and get their rank within criteria they earn gems , coins etc.

Example- A game in which their are 500 participants , and predefined Prize Distribution is Like…

Rank 1 gets 50000 coins
Rank 2 gets 40000 coins
Rank 3 to 50 gets 20000 coins
Rank 51 to 200 gets 5000 coins
Rank 201 to 500 gets 1000coins

If User plays the game and suppose he gets the rank 81 . So how can I check the distribution and award him the prize i.e, 5000 coins.

Can i use Hashmap to create some kind of key-value pair shown below..

HashMap<Integer, Integer> distribution = new HashMap<>();

Any suggestions will boost my work.


Well you could do a few loops if you want to use HashMaps.

HashMap<Integer, Integer> distribution = new HashMap<>();
//first and second place

//3rd through 50th place
for(int i = 3; i < 51; i++) 

//51 through 200th place
for(int i = 51; i < 201; i++) 
    distribution.add(i, 5000);

//201 through 500th place
for (int i = 201; i < 501; i++)
    distribution.add(i, 1000);

and tada you are done! However, unless you want it to run every single time, I would make distribution a static variable so you only have to run it once and it will stay for every run after that.