This is not homework. I'm designing an RPG, and for ability scores I am rolling 4d6, removing the lowest roll, and then adding the remaining total. What I have is below, and I was just curious if anyone had any other better suggestions. For brevity I've removed the roll actions, and I just plugged in four integers.
int[] rolls = { 6, 3, 2, 5 };
int abilityScore = rolls[0] + rolls[1] + rolls[2] + rolls[3];
int low = rolls[0];
for (int i = 1; i < rolls.length; i++)
{
if (rolls[i] < low)
{
low = rolls[i];
}
}
return abilityScore -= low;