views:

80

answers:

2

Want to code a key pad for an calculator. What I want to make is:

Keypad with keys from 0 to 9 Special keys: + - * / . =

My conceptual so far:

When a numeric key is pressed, convert it's int value into an string and append that string to the bufferString. That way the input value gets built up. When the user presses . (to make a float value), check if . is already in the bufferString. If it is, ignore that.

But: is that really a good way to go? Or should I do all this number input stuff pure mathematically?

+2  A: 

The idea is to convert a infix expression to a postfix expression (Reverse Polish notation) using the the Shunting yard algorithm. Then the postfix expression is easy to resolve.

decasteljau
A: 

Why converting from int to string when you could just pass directly a string? Everything else looks ok for me.

mouviciel