Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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.