What you are trying to do is evaluate a logical expression. In order to do this, you should first define a simple grammar for the family of expressions you want to be able to parse (your example is just one such expression), then build a parse tree from the input string, or at least convert the infix expression you have into RPN (Reverse Polish Notation). Once you've done that, you can use a simple stack machine to execute the RPN form of the expression.
If this doesn't make any sense to you, you've bitten off more than you can chew (for now) and I suggest reading up on Dijkstra's
Shunting-yard algorithm[
^]. It's not that hard once you understand how it works.
/ravi