Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Guess My Number Starter Code
- * Gauge Smithee
- * Mrs.Reagan
- *2/24/2020
- */
- import java.util.*;
- public class Program {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- Random rng = new Random();
- int secret = rng.nextInt(100) + 1;
- int guess;
- System.out.println("I'm thinking of a number 1 - 100.");
- System.out.print("Enter Guess: ");
- guess = sc.nextInt();
- while(guess != secret) {
- System.out.println("Nope.");
- if(guess > secret)
- System.out.println("lower");
- else
- System.out.println("higher");
- System.out.print("Guess Again: ");
- guess = sc.nextInt();
- }
- System.out.println("You got it!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement