Why Does My Prefix Expression Evaluator Program Miscalculate Any Addition or Subtraction?
问题 I have a program that is meant to take in a Queue<String> that contains the elements of a prefix operation (i.e. an operation that is stated "+ 4 2" instead of "4 + 2", which is infix), then output the integer answer (just assume that a double is never needed, okay?). It works correctly for any multiplication or division operation, but fails in any addition or subtraction operation, and worse, in an inconsistent manner. For example, the output to "- 5 1" is 5, which would suggest it's adding