One good way to make a command line calulator is to take in expressions in postfix notation ( because paranthesis are not require so it's a little simpler ).
Then all you have to do is make a stack.
and to evaluate the expression just ( in psuedocode),
Code:
while(true){
x = read();
if(x == aNumber) stack.push(x)
else if(x == anOperator) {
y = stack.pop();
z = stack.pop();
result = (x=='*')?y * z:
(x=='/')?y / z:
(x=='+')?y + z:
(x=='-')?y - z: y % z;
stack.push(result);
}
}
this will work for expressions of any size in postfiz notation.
If you want to use infix notation ( from the users point-of-view) you can convert the equation before you do this calulation.