|
-
April 16th, 2007, 07:11 AM
#1
Calculator help?
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.
-
April 16th, 2007, 07:15 AM
#2
Re: Calculator help?
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?
-
April 17th, 2007, 04:38 AM
#3
Re: Calculator help?
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|