if you type "123e31" in the command line.
the computer may read only "123"
i mean, how to make the system know that the input is wrong.
I think you're asking how to do input validation, am I correct?
If you want to make sure what is read in is only a number, I would recommend a while loop.
-
input initialized to be out of range
-
while (input is not in some range) {
-
input = readline/getline/getinput
-
}
-
If a string (e) is put in to an int, it won't be in that range, and the user will be re-prompted for the input.
Does that answer your question?