Let us take a look at the error:
An input of “5 . . 0” should display 5.0 : expected ‘5…0’ to equal ‘5.0’
Now, you will need to create some sort of conditional check that recognises if a number already has a decimal point in it, and, if true, should not allow another to be inserted.
The second error message:
The sequence “5 * - + 5” = should produce an output of “10” : expected ‘-25’ to equal ‘10’
So, one way to tackle this, is to check:
- Two or more operators are consecutively input, and neither is the
-operator: Then use only the latest input operator.
- Three or more operators are consecutively input: Then, use only the latest input. (regardless of whether operator is
You already have the functionality to correctly calculate the sequence:
If there is anything specific you are struggling with, ask a specific question.
Hope this helps
Thanks though. I understand the question just need help in how to solve both questions. I need the answers
Hmm… Well, we will not give you the answers, and discourage users who do. We will gladly help you find your way, and provide hints, but other than sudo-code, it would not be beneficial to give you much else.
Perhaps, if you are really struggling with the logic, take a break, learn some other things, complete some other projects, and, when you return, it will be that much easier. Usually does the trick for me.
Thanks. I do appreciate your help