# dunno just need help

wel I ahve a task for my school .
I have to make a game in pascal wich allous the player to chosea level (1 to 10) and number between 1 and 10. If it is level 1 he gats one chanse and so on at the end the score is calculated... plzz help me the levels wont work and the score neather
###### Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x

Commented:
You missed off the "level" - i.e. limited guesses...

program EX5;
(*guess a number rfom 1 to 10*)

USES crt;
var
X: integer;
level: integer;

procedure prepare;                                          (*prepares the screen*)
begin
//     CLRSCR;
WRITELN;
WRITELN('this is a game where you have to guess a number between 1 and 10');
end;

procedure chooselevel;
begin
level := -1;
while (level < 1) or (level > 10) do begin
WRITELN;
WRITE('choose level (1 to 10): ');
end;
end;

procedure chooseX;
begin
RANDOMIZE;
X := random(10) + 1;
end;

procedure play;
var
guess: integer;
wrong: boolean;
begin
wrong := TRUE;
while wrong and (level > 0) do begin
level := level - 1;
WRITELN;
WRITE('guess a number: ');
wrong := (guess <> X);
if wrong then begin
if level > 0 then
WRITE('wrong try again')
else
WRITE('wrong, you lose!')
end else
WRITE('YOU WIN');
end;
end;

begin
prepare;
chooselevel;
chooseX;
play;
end.
0

Commented:
have I understood properly ?

-your game consists in guessing a 1 to 10 number
-the level is the number of tries available ?
Am I right ?
0

Commented:
What code have you got so far?  If no code then what are your thought on an algorithm and the data?

mlmcc
0

Commented:
expalin game and i will give u a code
0

Author Commented:
here I've translated it (I live in belgium).
So this is what I've got so far

PROGRAM EX5;
(*guess a number rfom 1 to 10*)

USES crt;
VAR X :integer;
level :integer;
teller :byte;

PROCEDURE prepare; (*prepares the screen*)
BEGIN
CLRSCR;
WRITELN;
WRITELN ('this is a game where you have to guess a number between 1 and 10');
END; (*prepare*)

PROCEDURE chooselevel;
BEGIN
WRITELN;
WRITE ('choose level (1to10): ');
END; (*level*)

PROCEDURE chooseX;
BEGIN
RANDOMIZE;
X:=random(10)+1;
END; (*toevalswaarde*)

PROCEDURE play;
VAR guess :integer;
wright :boolean;
wrong  :boolean;
BEGIN
wrong=TRUE;
WHILE wrong DO begin
BEGIN
WRITELN;
WRITE ('guess a number: ');
juist:=(guess=X);
fout :=(guess<X) OR (gok>X);
IF wright THEN BEGIN
WRITE ('YOU WIN');
END;
IF wrong THEN BEGIN
WRITE ('wrong try again');
END;
END;
END;
END;

BEGIN
prepare;
chooselevel;
chooseX;
play;
END.
0

Commented:
You aren't setting wright & wrong correctly

PROCEDURE play;
VAR guess :integer;
wright :boolean;
wrong  :boolean;
BEGIN
wrong=TRUE;
WHILE wrong DO
BEGIN
WRITELN;
WRITE ('guess a number: ');
IF (guess = X) THEN
begin
WRITE ('YOU WIN');
wrong = false;
END
else
WRITE ('wrong try again');
END;
END;

Try that.

mlmcc
0

Commented:
I was just commenting and fixing his code.  Not trying to write what he hadn't tried yet.

mlmcc
0

Commented:
Have gotten what you needed?

mlmcc
0

Author Commented:
yup I've got al the info I need. Thanks its an A+ :-D
0

Commented: