0

The current code that I am writing is to have the user guess a random number between 0-10 and then having the code keep looping until they get the number right. So far this is what I have

public static void main(String[] args) {

    Scanner reader = new Scanner(System.in);
    System.out.println("A number between 0-10");
    //get user input for number
    n=reader.nextInt();

    Random generator = new Random(); 
    int number = (int) (Math.random()*10);
    int a = (int)number;
}

Now when I run the top portion I get the user input and when I run the bottom portion it prints out a random number between 1-10.

What I was wondering to do was how do I get that user input and make it a variable to compare to the random variable that I have set at int a?

Can anyone point me in the right direction?

Jesse
  • 8,605
  • 7
  • 47
  • 57

0 Answers0