l3r0y
April 16th, 2007, 07:11 AM
Ok, I want to make a calculator, but every example of a calculator is the same "enter two numbers to have them added" or whatever, I want it to be just so i can keep adding numbers until i want to stop, like a real calculator. I don't want exact code I just want to know what I should be looking at.
cilu
April 16th, 2007, 07:15 AM
You should create a loop. As long as you don't want to stop, provide input, the function you want to do (+, -, *, /, etc.) and perform the operation. The result you use for the next iteration of the loop. Did you follow?
bandwidthjunkie
April 17th, 2007, 04:38 AM
Your calculator object just needs to have data members representing:
# last input
# last operation (ie + - * / )
# current value
Then when you hit = it performs the last operation on the last input and the current value and updates current value. That is how a calculator works. Not with a loop.