Advertisement
Guest User

GuessNumber

a guest
Jul 9th, 2015
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6 0.47 KB | None | 0 0
  1. use v6;
  2.  
  3. my $randomNumber = round(100.rand());
  4.     my $attempts = 0;
  5.     while 1 {
  6.         my $userNumber = prompt('Choose a number between 0 and 100 : ');
  7.         if ($userNumber < $randomNumber) {
  8.             say "It's + !";
  9.             $attemps += 1;
  10.             say "Attempts : $attempts";
  11.         }
  12.         elsif ($userNumber > $randomNumber) {
  13.             say "It's - !";
  14.             $attemps += 1;
  15.             say "Attempts : $attempts";
  16.         }
  17.         else {
  18.             say 'Win !';
  19.             $attemps += 1;
  20.             say "Attempts : $attempts";
  21.             last;
  22.         };
  23.     };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement