Your logic is being naive. For each character in the input you are not only adding it to a class variable whose value may have been set in the previous iteration but you are also checking to see if it is an operator.

You should rewrite your if statements in such a way that it determines if it is a number, operator or junk (blank space). In addition, don't go on a character by character basis. Take the number as a whole until you reach an operator or a blank space, this way you can get 22, for example.