I haven't followed the whole flow but this does not look right
if ((optkey == '+')||(optkey == '-')||(optkey == 'x')||
(optkey == 1)||(optkey == '=')||(optkey == '*')){
I would expect
if ((optkey == '+')||(optkey == '-')||(optkey == 'x')||
(optkey == '1')||(optkey == '=')||(optkey == '*')){
i.e. '1' rather than just 1