Calculator - User Story #13

I don’t quite agree with this User Story…

13. If 2 or more operators are entered consecutively, the operation performed should be the last operator entered

If you press 5 * -1 you should get -5 right? But with the above User Story, the multiplication operation is disregarded, and the result becomes 4.

If you use the Google calculator, 5 * - + 5 results in -25, which I think is the correct answer. It shouldn’t be 10. Because - and + is a -, so that formula should equate to 5 * - 5 which is -25.

How would you represent that on an actual hand-held calculator? If you were to press 5 * - 1 on a standard desktop $5 calculator, you’d get 4. Instead, you would normally do the negative thing first (or have a button specifically for “sign”). So… on my calculator, when the display shows 0 initially, I can - 1 * 5 and off it goes, giving exactly the result you’d expect.

I understand the point you make, but that would be an equation parser that may or may not be beyond the scope of a simple calculator challenge.

Okay, just to be perfectly honest, one of the reasons I am objecting to this is because I made my Javascript calculator a long time ago which (I think) met the old user story requirements. But now with the new test suite, it doesn’t pass User Story #13 :sweat_smile:

You made a good point about desktop/handheld calculators… I actually don’t have one so I didn’t know what the results would be. I basically based the logic of my app on the results that you would get on Google’s online calculator. If you enter 5 * - 1 you get -5. However, I did notice just now that on an Apple calculator, you’d get 4.

How would I represent that on an actual handheld calculator? Initially I had thought that it would be what you’d see on the Google calculator… entering 5 X -1 would be displayed just like that on the screen…

55

And then pressing = would give you -5

36

There is no need to press a “positive/negative sign” button, and there isn’t even one on Google’s calculator app. You just push the normal - operator to create a negative number.

Then again maybe standard handheld calculators cannot display a formula on the screen, which is why if two operators are input, only the last one will be used, just like on an Apple calculator.

I guess what I would like to say now having thought about it more is that both types of logic can be considered valid. You can make a calculator in which 5*-1 = -5 and 5*-1 = 4 so perhaps User Story #13 should be updated to accept both results as valid.

Agree since it helps to save my time when I use it on the job (I am financial manager). However different situations requires different options but in that situation I prefer to work with percentage calculator that I’ve found from different sources on the article Since I had some experience with it I think that simple interface and good description should do the work for your needs. Btw do you want to ask something from me?