Calculator Chaining Operations Question

Calculator Chaining Operations Question
0.0 0

#1

In the calculator challenge, one of the user stories is:

User Story: I can keep chaining mathematical operations together until I hit the equal button, and the calculator will tell me the correct output.

Is it ok if the calculator evaluates after every step instead?

So instead of 2 + 3 + 4 = 9, it would be 2 + 3 gets evaluated to 5 first, and then 5 + 4 would evaluate to 9.


#2

I would assume so as long as the user could still enter it as 2 + 3 + 4 and then click/hit = to get the value 9. If you are asking if it would be ok if the user had to hit = after each pair of values plus operator is entered, then the answer is no.

If you are wondering if in the display, after each pair of values plus operator has been entered, there could be an evaluation made and the value displayed as other numbers are still being entered, then the answer is yes. Some campers have two displays. One for the current values being entered and one showing the current result after values have been entered.


#3

Yes, that is how I was going about it. You don’t need to hit = after each pair of values plus operator is entered, but immediately after typing 2 + 3 if you type another + you will see “5 +” on the screen letting you continue chaining without hitting = yet.

The problem with two displays comes with the order of operations. With my method 2 + 3 would eval to 5, then 5 * 4 would eval to 20, but on the second display it would show up as 2 + 3 * 4 which does NOT equal 20, so a second display doesn’t seem like a good idea to me.

EDIT: btw, the calculator on my chromebook does exactly this. 2 + 3 * 4 would give you 2 + 3 evaluating to 5, then 5 * 4 evaluating to 20.