Calculating value based on weighted percentage chance
I am writing a program in which I need to get a random value based on weighted chances and am having real difficulty.  An example of what I need to do:

a = 50%, b = 30%, c = 10%, d = 10%

In this example, I need to be able to get a random value, a,b,c or d, with the value coming back being as 'a' 50% of the time, b 30% of the time, etc...

Many thanks
Calculating value based on weighted percentage chance
===

I am writing a program in which I need to get a random value based on weighted chances and am having real difficulty.  An example of what I need to do:

a = 50%, b = 30%, c = 10%, d = 10%

In this example, I need to be able to get a random value, a,b,c or d, with the value coming back being as 'a' 50% of the time, b 30% of the time, etc...

Many thanks