You need to declare num
outside of the loop.
int num;
do
{
System.out.println("Enter a number that has only five digits ");
num = console.nextInt();
} while (num < 10000 || num > 99999);
This is due to variable scoping. It's a bit annoying, but a variable declared in the do
portion of a do-while isn't available in the while
portion.