A simple Java calculator that runs in the terminal.
javac CommandLineDemo.javajava CommandLineDemo <number1> <operator> <number2>
Examples
java CommandLineDemo 10 + 5
java CommandLineDemo 15 - 3
java CommandLineDemo 7 * 6
java CommandLineDemo 20 / 4
Available Operations
+ : Addition
- : Subtraction
* : Multiplication
/ : Division
Example Output
$ java CommandLineDemo 10 + 5 Result: 15.0
$ java CommandLineDemo 20 / 0 Error: Division by zero!
Requirements
Java (JDK 8 or higher)
Quick Start
Save the Java code as CommandLineDemo.java
Open a terminal in the same folder
Compile the program:
javac CommandLineDemo.java
Run the calculator:
java CommandLineDemo 5 + 3
Use "*" or \* to multiply
java CommandLineDemo 5 "*" 3
java CommandLineDemo 5 \* 3