0

I still fail test case 4 & 5 in mathematics code challenge.is there anything I miss?

https://code.sololearn.com/c43bOYZEb77G/?ref=app

7th Feb 2023, 4:31 AM
Killiam Chances
Killiam Chances - avatar
5 ответов
+ 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?
7th Feb 2023, 4:48 AM
Ausgrindtube
Ausgrindtube - avatar
+ 1
Oh,I see thanks
7th Feb 2023, 5:02 AM
Killiam Chances
Killiam Chances - avatar
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.
7th Feb 2023, 5:25 AM
ArsenicolupinIII
0
Do you know anything about evaluating that kind of expression?
7th Feb 2023, 6:50 AM
Killiam Chances
Killiam Chances - avatar