Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Random;
- public class Problem2 {
- public static void main(String[] args)
- {
- Scanner userinput = new Scanner(System.in);
- Random rand = new Random();
- int randint = rand.nextInt(10);
- int guess = 0;
- System.out.println("Guess a number between 1 and 10:");
- guess = userinput.nextInt();
- while (guess != randint) {
- System.out.println("Incorrect, Try again:");
- guess = userinput.nextInt();
- }
- System.out.println("You've guessed the number!");
- System.out.println("You win!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement