If user is allowed to type in non-numbers, then the program should first read in the user's input as a string. Then it should verify whether the string can be interpreted as a number. If it can be, convert the string to a number...
This question was recently explained in detail in this thread: