Hi Dustin,
I guess you'd probably have to use Regex (regular expressions). Try looking it up (read the
Java tutorials).
Then you can do something like encode the fact that you want (one or many digits), followed by (only one decimal point), followed by (one or more digits), followed by (one or more spaces), followed by the operator (*, /, +, -), followed by (one or many digits, only one decimal point, and again, one or more digits).
I'm not sure but something like: \d+([\.]\d+)?\s*[\*\+\-\/]\s*\d+([.]\d+)?
Note, that since Java uses the '\' character as an escape character, the regex will end up like this in Java:
\\d+([\\.]\\d+)?\\s*[\\*\\+\\-\\/]\\s*\\d+([.]\\d+)?
i.e. double every backslash.
Anyway, here's the English version:
1 or more digits, one or no ". followed by 1 or more digits", 0 or more spaces, either *, +, -, or /, 0 or more spaces, and the rest is similar to the first bit.
Then you'd have to compile this
pattern and match it with the users' input. Read the Java tutorials for more detail.
Regards,
Justin