Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package exa;
- import java.util.*;
- class exa
- {
- static Random Generator = new Random();
- static Scanner input = new Scanner(System.in);
- public static void main(String[]args)
- {
- int bnum,cnum,snum,chance,quit=0;
- System.out.print("Choose Small Number: ");
- snum = input.nextInt();
- System.out.print("Choose Big number : ");
- bnum = input.nextInt();
- System.out.print("How much Chance ? : ");
- chance = input.nextInt();
- int rand = Generator.nextInt(bnum) + snum;
- while(quit==0)
- {
- System.out.print("Guess the number : ");
- cnum = input.nextInt();
- chance -= 1;
- if(cnum==66)
- {
- System.out.print(rand);
- }
- else if(chance<=0)
- {
- System.out.print("You can't guess more :0");
- quit=1;
- }
- else if(cnum==rand)
- {
- System.out.print("You guessed true ! the random number is " + rand);
- quit=1;
- }
- else if(cnum<rand)
- {
- System.out.print("The number is smaller then the random number\r\n");
- }
- else if(cnum>rand)
- {
- System.out.print("The number is bigger then the random number\r\n");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment