I am making a program and cannot figure out how to make my scanner input only recognize numbers. Here is what I mean.
System.out.print(" What is the distance in feet:" );
//ask the user to input variables
Distance = keyboard.nextDouble();
What can I put after the distance input in order to allow me to output some sort of message telling the user they didn't enter a number.
I thought maybe starting with something like
if (Distance != double)
System.out.print ("You did not enter a valid character, please enter again."
but that does not work. Any suggestions?