Shad0w

Untitled

Sep 22nd, 2011
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. package exa;
  2. import java.util.*;
  3. class exa
  4. {
  5.     static Random Generator = new Random();
  6.     static Scanner input = new Scanner(System.in);
  7.     public static void main(String[]args)
  8.     {
  9.         int bnum,cnum,snum,chance,quit=0;
  10.         System.out.print("Choose Small Number: ");
  11.         snum = input.nextInt();
  12.         System.out.print("Choose Big number : ");
  13.         bnum = input.nextInt();
  14.         System.out.print("How much Chance ? : ");
  15.         chance = input.nextInt();
  16.         int rand = Generator.nextInt(bnum) + snum;
  17.         while(quit==0)
  18.         {
  19.             System.out.print("Guess the number : ");
  20.             cnum = input.nextInt();
  21.             chance -= 1;
  22.             if(cnum==66)
  23.             {
  24.                 System.out.print(rand);
  25.             }
  26.             else if(chance<=0)
  27.             {
  28.                 System.out.print("You can't guess more :0");
  29.                 quit=1;
  30.             }
  31.             else if(cnum==rand)
  32.             {
  33.                 System.out.print("You guessed true ! the random number is " + rand);
  34.                 quit=1;
  35.             }
  36.             else if(cnum<rand)
  37.             {
  38.                 System.out.print("The number is smaller then the random number\r\n");
  39.             }
  40.             else if(cnum>rand)
  41.             {
  42.                 System.out.print("The number is bigger then the random number\r\n");
  43.             }
  44.         }
  45.     }
  46. }
Add Comment
Please, Sign In to add comment