Ad
  • Default User Avatar

    I think I spotted a mistake here.

    The kata involves the operator () too, which is not included in the code.

    The description says "Create a simple calculator that given a string of operators (), +, -, *, / and numbers separated by spaces returns the value of that expression".

    So if I try
    expression = "2 / ( 3 + 1 )"
    It shows error since () isn't included.

    Exception in thread "main" 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:549)
    at java.base/java.lang.Double.valueOf(Double.java:512)
    at Test.main(Test.java:19)

    Please check that up in the test cases.

    Otherwise this is really a short and simple answer I would say.