Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Thomas Phillips
- // Partner Quatman
- //Mrs.Regan
- //Guess my number Program
- import java.util.*;
- public class Program {
- public static void main(String[] args) {
- //This tells the lowest value.
- int value = 1;
- //This scans the code.
- Scanner sc = new Scanner(System.in);
- //This is the random number generator which makes it randomly choose a number.
- Random rng = new Random();
- //Defines the value.
- value = rng.nextInt();
- //Makes the int secret from you so you don't see the correct anwser.
- int secret = rng.nextInt(100) + 1;
- int guess;
- //Prints the line "I'm thinking of a number 1 - 100."
- System.out.println("I'm thinking of a number 1 - 100.");
- //Does the same as the line above prints out "Enter Guess: "
- System.out.println("Enter Guess: ");
- guess = sc.nextInt();
- while(guess != secret) {
- //If guess is lower it will say higher.
- if ( guess < secret)
- System.out.println("Higher");
- else
- //If guess is higher it will say lower.
- System.out.println("Lower");
- guess = sc.nextInt();
- }
- System.out.println("You got it.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement