Ad
  • Custom User Avatar

    Input for failing test cases is not "+". The error means that at some point, your oslution attempts to parse the string "+" as a number.

    Your solution crashes for following inputs:

    Input expression: 12*-1
    For input string: "+"
    Stack Trace
    java.lang.NumberFormatException: For input string: "+"
    	at java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
    	at java.base/jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
    	at java.base/java.lang.Double.parseDouble(Double.java:651)
    	at MathEvaluator.getNumberOnTheRight(MathEvaluator.java:91)
    	at MathEvaluator.calculates(MathEvaluator.java:72)
    	at MathEvaluator.calculate(MathEvaluator.java:30)
    	at TestSuite$MathEvaluatorTest.test(TestSuite.java:57)
      [...]
    
    Input expression: 12* 123/-(-5 + 2)
    For input string: "-"
    Stack Trace
    java.lang.NumberFormatException: For input string: "-"
    	at java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
    	at java.base/jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
    	at java.base/java.lang.Double.parseDouble(Double.java:651)
    	at MathEvaluator.getNumberOnTheRight(MathEvaluator.java:91)
    	at MathEvaluator.calculates(MathEvaluator.java:72)
    	at MathEvaluator.calculate(MathEvaluator.java:30)
    	at TestSuite$MathEvaluatorTest.test(TestSuite.java:57)
      [...]
    
    Input expression: (123.45*(678.90 / (-2.5+ 11.5)-(((80 -(19))) *33.25)) / 20) - (123.45*(678.90 / (-2.5+ 11.5)-(((80 -(19))) *33.25)) / 20) + (13 - 2)/ -(-11) 
    For input string: "-"
    Stack Trace
    java.lang.NumberFormatException: For input string: "-"
    	at java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
    	at java.base/jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
    	at java.base/java.lang.Double.parseDouble(Double.java:651)
    	at MathEvaluator.getNumberOnTheRight(MathEvaluator.java:91)
    	at MathEvaluator.calculates(MathEvaluator.java:72)
    	at MathEvaluator.calculate(MathEvaluator.java:30)
    	at TestSuite$MathEvaluatorTest.test(TestSuite.java:57)
      [...]
      
    Input expression: 12 * -123
    For input string: "+"
    Stack Trace
    java.lang.NumberFormatException: For input string: "+"
    	at java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
    	at java.base/jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
    	at java.base/java.lang.Double.parseDouble(Double.java:651)
    	at MathEvaluator.getNumberOnTheRight(MathEvaluator.java:91)
    	at MathEvaluator.calculates(MathEvaluator.java:72)
    	at MathEvaluator.calculate(MathEvaluator.java:30)
    	at TestSuite$MathEvaluatorTest.test(TestSuite.java:57)
    	[...]
    

    All stacktraces seem to originate from MathEvaluator.getNumberOnTheRight(MathEvaluator.java:91), so you need to search for error in your solution somewhere around there.

  • Custom User Avatar

    Hello.

    I use the Java language.

    The tests pass, but when I try to send the code, writes: "For input string:"+"." Then follows Stacktrace, in which: "Java.lang.numberformatexception: for input string:"+". Next, Stacktrace ...".

    My calculator returns 0.0 with a transferred line "+". I don’t understand what needs to be returned to go these tests.

    I think that the exception should be returned to such a line: "+". Since this is not a mathematical expression. I think the decision is the correctness of the exclusion. But I can’t fully understand in which form to return the exception.

    Who can direct to the right thought, please write?