Change
for(x = 0; x < num +1; x++)
to
for(x = 0; x < num; x++)
Also you might have meant
for(boolean guessed = false; guessed == true;) // notice == instead
and then setting this flag to true
within this(outer) for
loop.
solved ava.lang.StringIndexOutOfBoundsException: String index out of range: 9 at java.lang.String.charAt(String.java:658)