Your program never reaches if(userEnteredNumber == 6)
with 6 value, because if userEnteredNumber
is 6, the first condition will grab it:
if (userEnteredNumber != 1 && userEnteredNumber !=2 && userEnteredNumber != 3
&& userEnteredNumber != 4 && userEnteredNumber != 5) {
throw new Exception();
}
then it throws exception, and it is catch
ed within loop block. And any number other than 1, 2, 3, 4, 5, 6 is the same. So the loop never ends.
I don't like your code-style at all. But if you want to do it this way, you shall add userEnteredNumber != 6
to first if condition.