Advertisement
Gauge1417

Untitled

Feb 24th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. /* Guess My Number Starter Code
  2. * Gauge Smithee
  3. * Mrs.Reagan
  4. *2/24/2020
  5. */
  6.  
  7. import java.util.*;
  8.  
  9. public class Program {
  10.  
  11. public static void main(String[] args) {
  12.  
  13. Scanner sc = new Scanner(System.in);
  14. Random rng = new Random();
  15. int secret = rng.nextInt(100) + 1;
  16. int guess;
  17.  
  18. System.out.println("I'm thinking of a number 1 - 100.");
  19.  
  20. System.out.print("Enter Guess: ");
  21. guess = sc.nextInt();
  22.  
  23. while(guess != secret) {
  24. System.out.println("Nope.");
  25.  
  26. if(guess > secret)
  27. System.out.println("lower");
  28.  
  29. else
  30. System.out.println("higher");
  31.  
  32. System.out.print("Guess Again: ");
  33. guess = sc.nextInt();
  34. }
  35.  
  36. System.out.println("You got it!");
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement