
Originally Posted by
Imagine
And would something like:
Switch(random(A)) of:
1..x : ------
x..y : ------
y..z : ------
z..A : ------
work? And how would I be able to input more options?
Yes that would work, let's take your lottery idea, you would have everybody pick 5 numbers, at the end of it you want to email everybody saying how many numbers they got right:
Simba Code:
program new;
Var
NumberCorrect : array of integer;
Messages : array of String;
i : integer;
begin
//The first person got 4 right, the next got 0 etc...
NumberCorrect := [4, 0, 3, 2, 2, 5, 3];//This array could be any length (dependant on the number of people in your lottery)
Messages := ['Sorry you didn''t get any right, better luck next time', //your messages dependant on the number correct
'You only got 1 number correct, sorry',
'You managed to get 2 correct, well done',
'You got 3 correct and won £20, well done',
'You got 4 numbers correct and won £200, well done',
'You won the jackpot!!!!'];
for i := 0 to high(NumberCorrect) do //for each person it prints out their result
WriteLn('Person '+IntToStr(i)+' - '+Messages[NumberCorrect[i]]);
end.
Code:
Compiled successfully in 31 ms.
Person 0 - You got 4 numbers correct and won £200, well done
Person 1 - Sorry you didn't get any right, better luck next time
Person 2 - You got 3 correct and won £20, well done
Person 3 - You managed to get 2 correct, well done
Person 4 - You managed to get 2 correct, well done
Person 5 - You won the jackpot!!!!
Person 6 - You got 3 correct and won £20, well done
Successfully executed.