So the task is to create our own parser for a expression calculator. For Example:
Input: 3+2*1-6/3 Output: 3
Input: 3++2 Output: Invalid Expression
Input
Rather than re-invent the wheel you could use a parser generator such as JavaCC or antlr, which is specifically designed for this kind of task. This is a nice example of a simple expression parser and evaluator in a couple of dozen lines of JavaCC.