This is for a final project for my Java class. I've made the GUI and have no problems there, and I can tell what button was clicked.

What I need help with is the process for determining what happens after a click. For example, if it is the first click, a - would start a negative number, but if it is the second (or later) click, it would store the current number and then start a subtraction process. Or, after entering a number, a function (add or whatever) and a second number and press =, you get a result. But then, if you enter a function (add, etc.) then you use result as the first number in your next equation. But, if you enter a number at that point, it should clear display and allow you to enter a number, etc.

So... has anyone written a calculator in *any* language? I have enough experience with enough languages to be able to read most source, so if you have something that can let me see the process, I'd appreciate it.