?
Solved

dunno just need help

Posted on 2003-03-16
10
Medium Priority
?
231 Views
Last Modified: 2010-04-16
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
Comment
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
10 Comments
 
LVL 15

Expert Comment

by:VGR
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

by:mlmcc
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

by:ILE
ID: 8147049
expalin game and i will give u a code
0
Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

 

Author Comment

by:ViP
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): ');    
READLN (level);
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: ');
      READLN (guess);
      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;
    READLN;
END;


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

Expert Comment

by:mlmcc
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: ');
     READLN (guess);
     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

by:
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): ');
    READLN(level);
  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: ');
    READLN(guess);
    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;
  READLN;
end;

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

Expert Comment

by:mlmcc
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

by:mlmcc
ID: 8189077
Have gotten what you needed?

mlmcc
0
 

Author Comment

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

Expert Comment

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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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.

Join & Ask a Question