View Single Post
Join Date: Nov 2008
Posts: 8
Reputation: smorton123 is an unknown quantity at this point 
Solved Threads: 0
smorton123 smorton123 is offline Offline
Newbie Poster

Pascal : Random Num Generator

 
0
  #1
Nov 22nd, 2008
I'm making a project in Xcode Pascal, the program asks the user if they want to begin then selects seven random in a 'lottery' style game. I wanted to save the numbers into an array so I could select any one of the seven numbers at one time. At the moment I cannot get the program to read the numbers or save them. I know how to use arrays but I cant seem to get them to work for this program. Any help would be greatly appreciated.

program test;
uses
EmptyPlaceHolderUnit;


var
yn : string;
i : integer;
bonus: integer;

procedure start_game (yn: string; i:integer; bonus: integer);
var
subscript: integer;

begin

writeln('Do you want to begin? Please enter Y / N ( Remember to use capital letters! )'); {asks user if they want to begin}
readln(yn);
if (yn = 'Y') then {Will begin program if 'Yes' is entered}
writeln ('The program will now begin') else {Program will end if 'No' is entered}
writeln('You have chosen not to run the program');


if (yn = 'Y') then

begin

writeln (' ');
writeln (' And tonights Lottery Balls are...');
writeln (' ');

randomize;

for i := 1 to 7 do
writeln(random(50),' '); {Selects 6 random integers from the range 0 - 49}

writeln(i);
end;
end;

begin
start_game(yn, i, bonus);
end.
Reply With Quote