Solved

# dunno just need help

Posted on 2003-03-16
Medium Priority
231 Views
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
0
Question by:ViP
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• Learn & ask questions
• 4
• 2
• 2
• +2

LVL 15

Expert Comment

ID: 8146445
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

LVL 101

Expert Comment

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

mlmcc
0

LVL 3

Expert Comment

ID: 8147049
expalin game and i will give u a code
0

Author Comment

ID: 8147053
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

LVL 101

Expert Comment

ID: 8147170
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

LVL 1

Accepted Solution

SimesA earned 750 total points
ID: 8152157
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

LVL 101

Expert Comment

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

mlmcc
0

LVL 101

Expert Comment

ID: 8189077
Have gotten what you needed?

mlmcc
0

Author Comment

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

LVL 15

Expert Comment

ID: 8189808
so now please accept someone's answer 8-)
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
In this blog post, weâ€™ll look at how using thread_statistics can cause high memory usage.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to fâ€¦
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as formâ€¦
###### Suggested Courses
Course of the Month15 days, 8 hours left to enroll

#### 741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.