0
I still fail test case 4 & 5 in mathematics code challenge.is there anything I miss?
5 Respuestas
+ 4
I think you miss any equation that uses multiple operations.
If the inputs looked like this:
8
(2+2+2+2) (5/3) (3*3)
Your code doesn't work, does it?
+ 1
Oh,I see thanks
0
i believe that the code is trying to evaluate simple mathematical expressions and find if the result matches the given value, the problem with the code is that it only evaluates a single character operator between two numbers. To handle multiple characters of the expression and also the order of operations, you can use stack data structures and perform the calculation accordingly. Also, the code is using "result+=" to store the result, but this should be changed to simply "result =" since each calculation will overwrite the previous result, finally, the code should be handling cases for the expressions where it contains a wrong operator or the number format is incorrect, which may result in NumberFormatException.
0
Do you know anything about evaluating that kind of expression?