Loading ...
Sorry, an error occurred while loading the content.
 

Re: [PBML] Help please , thanks in advance

Expand Messages
  • Jadi, SoftHome
    ... when you use rand, the result will be a floating point number ( say 1.857493 ) so you have to use int : my $target = int (rand()*3); so int ( 1.857493
    Message 1 of 3 , Feb 2, 2003
      there are 2 errors in your code... this is the first one :

      : : my $target = rand()*3;

      when you use rand, the result will be a floating point number
      ( say 1.857493 ) so you have to use "int" :

      my $target = int (rand()*3);

      so "int ( 1.857493 )" will be " 1 ";

      and this is the seccond mistake :

      :: $userchoice eq <>;

      "eq" means "is it equal ?" when you want to say "make it equal"
      you have to use " = " instead...

      $userchoice = <>;

      and your programmed will work great :

      This is the classic game Rock Paper Scissors
      > rock
      jadi : rock cpu : 2
      Computer picked SCISSORS you win!!

      as you can see I've added some more lines and \n to it !


      Jadi
    Your message has been successfully submitted and would be delivered to recipients shortly.