Firstly, please format your code using highlight tags. See my signature.
The
<Random>.nextInt(int number) methods returns integers between
0 and
number - 1, inclusive. So, for example, if you used
<Random>.nextInt(7) you would get a random integer ranging from 0 to 6. Similarly, if you want numbers from 2 to 4, not starting at 0, you could use
<Random>.nextInt(3) + 2.
If that doesn't help, use some System.println()'s to help display what your random numbers are.
System.out.println("Please guess number 1. The number must be within zero and three. ";
userAnswer = keyboard.nextInt();
This looks alright, but think: what if the user enters a number less than one or greater than three, or maybe not even a number at all? You should probably use some
input validation and a while loop to make sure that the user doesn't play any dirty tricks to crash your program.