Advertisement
Strike15

Untitled

Feb 14th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. //Thomas Phillips
  2. // Partner Quatman
  3. //Mrs.Regan
  4. //Guess my number Program
  5.  
  6. import java.util.*;
  7.  
  8. public class Program {
  9.  
  10. public static void main(String[] args) {
  11.  
  12. //This tells the lowest value.
  13. int value = 1;
  14. //This scans the code.
  15. Scanner sc = new Scanner(System.in);
  16. //This is the random number generator which makes it randomly choose a number.
  17. Random rng = new Random();
  18. //Defines the value.
  19. value = rng.nextInt();
  20. //Makes the int secret from you so you don't see the correct anwser.
  21. int secret = rng.nextInt(100) + 1;
  22. int guess;
  23.  
  24. //Prints the line "I'm thinking of a number 1 - 100."
  25. System.out.println("I'm thinking of a number 1 - 100.");
  26.  
  27. //Does the same as the line above prints out "Enter Guess: "
  28. System.out.println("Enter Guess: ");
  29. guess = sc.nextInt();
  30.  
  31. while(guess != secret) {
  32. //If guess is lower it will say higher.
  33. if ( guess < secret)
  34. System.out.println("Higher");
  35.  
  36. else
  37. //If guess is higher it will say lower.
  38. System.out.println("Lower");
  39.  
  40. guess = sc.nextInt();
  41. }
  42. System.out.println("You got it.");
  43. }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement