This is command-line calculator which supports 4 basic arithmetic operations(+ - * /). Implemented as part of Svitla Systems, Inc. interview "home work".
- The calculator should use standard input and standard output
- It should implement the four standard arithmretic operators
- The calculator should handle errors and recover gracefully
- The calculator should exit when it receives a q command or an end of input indicator (EOF / Ctrl+D)
I identified that project should be "interactive cli application" which means run once and make a dialog. So I had to skip following libraries:
- commons-cli - doesn't support interactive cli
- picocli - the same:
Also there were applicable libs:
- Spring Shell - requires deep investigation to customize for my needs
- picocli-shell-jline3 - looks complicated in code
A high-level description of your solution Reasoning behind your technical choices, including architectural Trade-offs you might have made, anything you left out, or what you might do differently if you were to spend additional time on the project How to run your code, if applicable Link to the hosted application, if applicable
STORY: not used commons-cli(not interactive): http://zetcode.com/java/console/ not used picocli(same):
- https://picocli.info/migrating-from-commons-cli.html
- https://www.baeldung.com/java-picocli-create-command-line-program alternative Spring Shell https://docs.spring.io/spring-shell/docs/current/reference/htmlsingle/ alternative picocli-shell-jline3 https://github.com/remkop/picocli/tree/master/picocli-shell-jline3
Application requires Java 8 to build.
Clone code from GitHub, make sure you have some JRE/JDK installed and build the project:
$ cd rpn_calculator
$ sh gradlew clean build jar
Application requires Java 8 to run.
$ cd rpn_calculator/build/libs
$ java -jar rpn_calculator-1.0-SNAPSHOT.jar
$ > 1 1 +
Hints!
- use
CTRL+D
orq
commands to exit application interactive mode - use
-help
for some help
GNU GPL v3
- task https://gist.github.com/joedean/078a62b9ec03b38dfc519b3a5f168b07
- RPN wiki https://en.wikipedia.org/wiki/Reverse_Polish_notation
- java colutions overview https://dzone.com/articles/interactive-console-applications-in-java
- code examples:
- gradle runnable jar https://gist.github.com/TurekBot/4a3cd406cb52dfd8bfb8022b982f0f6c
- cli reader https://stackoverflow.com/a/10412853
- online tester https://www.dcode.fr/reverse-polish-notation