This is an assignment: so that you can learn concepts of programming language, OOP, data structures.
I am unsure why ScriptEngine is being used since you are required to make the parser, not show its usage.
Simple Guide to Mathematical Expression Parsing[
^], this article has good material on expression parsing.