Loop
Is this possible to condense down into a loop?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
if (selection_two == 0){
user_winnings_two = 100 * multiple_chips;
}
if (selection_two == 1){
user_winnings_two = 500 * multiple_chips;
}
if (selection_two == 2){
user_winnings_two = 1000 * multiple_chips;
}
if (selection_two == 3){
user_winnings_two = 0 * multiple_chips;
}
if (selection_two == 4){
user_winnings_two = 10000 * multiple_chips;
}
if (selection_two == 5){
user_winnings_two = 0 * multiple_chips;
}
if (selection_two == 6){
user_winnings_two = 1000 * multiple_chips;
}
if (selection_two == 7){
user_winnings_two = 500 * multiple_chips;
}
if (selection_two == 8){
user_winnings_two = 100 * multiple_chips;
}
|
the simpliest way is to use an array:
1 2 3 4
|
int multiples[] = {100,500,1000,0,10000,0,1000,500,100};
if (selection_two >= 0 && selection_two <= 8)
user_winnings_two = multiples[selection_two] * multiple_chips;
|
Last edited on
Topic archived. No new replies allowed.