I thought making a calculator would be a fairly simple practice exercise, but it's turning out more complicated than I had anticipated.
I don't want the user to be able to type a closing bracket if there isn't a matching opening bracket. I know how to search the string for specific characters, but I'm having trouble figuring out how to determine if there is an open parenthesis that needs to be closed.
Basically I want "(3+5)" to be possible, but "3+5)" to be impossible to type.
05-11-2013, 10:25 AM
Count the opening bracket and decrease this positive or null number with each closing bracket !
05-11-2013, 10:27 AM
You're going to have to count the number of left and right parenthesis in the user's entry and see if they match. On a good day, you'll also check to see that they're in an acceptable order. That is,