In C, not Java, and assuming A, B, and C are ints...
Code:
int foo(int a, int b, int c)
{
float total = a + b + c;
float aThreshold = a / total;
float bThreshold = aThreshold + (b / total);
float n = rand() / RAND_MAX; //don't know what this constant is called in Java
if(n <= aThreshold)
return a;
if(n <= bThreshold)
return b;
return c;
}
Test it to make sure the algorithm is correct before using it. I'm tired and not thinking straight.