Dear Sir / Madam,

The following is the game of Rock, Paper, Scissors. But I don't know why computer is always choose Rock.

My Answer:-

program RPS5;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  ourcrt;

var
        Computer : integer;
        Choice, Move : char;

begin

   repeat
     writeln('Rock(R), Paper(P), Scissors(S)');
     readln(Choice);
   until (Choice = 'R') or (Choice = 'P') or (Choice = 'S');

case Choice of
'R': writeln('You have chosen Rock');
'P': writeln('You have chosen Paper');
'S': writeln('You have chosen Scissors');
end;

Computer:= random (2);

case Computer of
0:    begin   writeln('Computer have chosen Rock');
              Move:='R';
                if  Move=choice then begin Writeln('Draw') end
                  else
                   if Choice='S' then begin Writeln ('You lose') end
                     else writeln('You win') end;

1:    begin   writeln('Computer have chosen Paper');
              Move:='P';
                if  Choice=Move then begin Writeln('Draw') end
                 else
                  if Choice='R' then begin Writeln ('You lose') end
                   else writeln('You win') end;

2:    begin   writeln('Computer have chosen Scissors');
              Move:='S';
                if  Choice=Move then begin Writeln('Draw') end
                 else
                  if Choice='P' then begin Writeln ('You lose') end
                   else writeln('You win') end;
end;

sleep (10000);
end.

Could you tell me what is wrong of my answer,

Cheers,

Here is the fixed version of your program :)

(*
Dear Sir / Madam,

The following is the game of Rock, Paper, Scissors.
But I don't know why computer is always choose Rock.

My Answer:-
 *)
Program RPS5;

{$APPTYPE CONSOLE}

Uses
SysUtils;
var Computer : integer;
    Choice, Move : char;
Begin //main
   Repeat
      WriteLn('Rock(R), Paper(P), Scissors(S)');
      ReadLn(Choice);
   Until (Choice = 'R') Or (Choice = 'P') Or (Choice = 'S');
   Case Choice Of
      'R': WriteLn('You have chosen Rock');
      'P': WriteLn('You have chosen Paper');
      'S': WriteLn('You have chosen Scissors');
   End;//case
   Randomize;  (* <-- you forget about randomize,not? *)
   Computer:= Random(2);
   Case Computer of
      0: Begin
            WriteLn('Computer have chosen Rock');
            Move:='R';
            If (Move=choice) Then Begin
               Writeln('Draw')
            End //'if' move
            Else Begin
               If Choice='S' Then Begin
                  WriteLn ('You lose')
               End //'if' choice
               Else WriteLn('You win');
            End;//else
         End;//case 0
      1: Begin
            WriteLn('Computer have chosen Paper');
            Move:='P';
            If (Choice=Move) Then Begin
               Writeln('Draw');
            End
            Else Begin
               If (Choice='R') Then Begin
                  Writeln ('You lose');
               End
               Else writeln('You win');
            End;
         End;//case 1
      2: Begin
           WriteLn('Computer have chosen Scissors');
           Move:='S';
           If (Choice=Move) Then Begin
              Writeln('Draw');
           End
           Else Begin
              If (Choice='P') Then Begin
                 Writeln ('You lose');
              End
              Else writeln('You win');
           End;
         End;//case 2
   End;//case main

  //sleep(10000);
  ReadLn; //I put this line,waiting for press the enter button
End.//of main program

(*
-=Note By FlamingClaw=-
I dont know your 'ourcrt',so I put it out  
Sorry for formatting your program,but now already readable...to me.
You forget about randomize!!!
-=Created By FlamingClaw=-
-=2009.04.04=-
*)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.