I try not to do this, but I need some help. Attempted to finish the project quickly, but ended up coding myself into a corner.
Here’s the code: Hello code
I’ve finished the majority of the project and fulfill all but one error, " 13. If 2 or more operators are entered consecutively, the operation performed should be the last operator entered (excluding the negative (-) sign."
In particular, “The sequence “5 * - + 5” = should produce an output of “10” : expected ‘-25’ to equal ‘10’”. My code allows for the input, but does not perform the logic correctly as it doesn’t handle the operations (5*-+5 => 5*-5 => -25).
The workaround I do have, which parses the string and clears every operation beside the final one, breaks further logic. I also attempt to count the number of entered operations in a row, but this variable (operationCount) doesn’t function properly with my logic.
I’ve also attempted to parse the entire display value as array, which I’ll do again if suggested. Just seemed like more refactoring than necessary.
The problem is in my switch function, handleOp (=). I didn’t separate the numerical values either, which furthers the problem. I’m going to try from scratch again, but I figured since I was so close I should toss it up to the community before another go. Thank you!