Advertisement
IanO-B

Untitled

Nov 29th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.Random;
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6. Scanner keyboard = new Scanner(System.in);
  7. Random r = new Random();
  8. int Low = 1;
  9. int High = 10;
  10. int actual = r.nextInt(High - Low) + Low;
  11. //int actual = 1 + r.nextInt(10);
  12. //System.out.println(actual);
  13.  
  14. System.out.println("I have chosen a number between 1 and 10. Try to guess it :albiClout:");
  15. int Tries = 1;
  16. System.out.println("Your guess: ");
  17. int guess = keyboard.nextInt();
  18. while(guess != actual){
  19. System.out.println("That is incorrect. Try again.");
  20. System.out.println("Your guess: ");
  21. guess = keyboard.nextInt();
  22. Tries++;
  23. }
  24. System.out.println("That's right! You're a good guesser :aPogU:");
  25. System.out.println("It took you " +Tries+ " tries.");
  26.  
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement