and I am getting unexpected results for some reason when I type 2 + 2 q the answer will be 2 yet I add the rval to val but it only seems to hold the value of the last rval instead of adding it to val
you type 2+2q
it does some things and ends up in the + part of the switch statement.
at this point, cout of val is zero, then you add 2 to it, then it hits q, and it exits, answer = 2.
so the root problem is that val = 0 when it should be assigned 2 somewhere, somehow.
to see this, add print statements before and after the val += statement.