The Unsecure Calculator is a simple command-line-based calculator written in Java. It supports basic arithmetic operations, value storage, and retrieval. This project is intended for educational purposes is "unsecure".
- Addition: Adds two numbers.
- Subtraction: Subtracts the second number from the first.
- Multiplication: Multiplies two numbers.
- Division: Divides the first number by the second.
- Modulo: Computes the remainder of dividing the first number by the second.
- Store: Stores the last result in memory.
- Retrieve: Retrieves the stored value.
- Clear: Clears the stored value.
- Exit: Exits the calculator.
- Java Development Kit (JDK) 8 or higher
- Internet connection
-
Clone the repository or download the source files to your local machine.
-
Navigate to the project directory. Use a terminal or command prompt to navigate to the directory where the source files are located.
-
Compile the Java files.:
./gradlew build
-
Run the program. Execute the following command to start the calculator:
./gradlew run
Once the program is running, you can type in commands to perform operations. Below are examples of the available commands:
-
Add: Adds two numbers.
add 2 4
Output:
Result: 6.0 -
Subtract: Subtracts the second number from the first.
subtract 5 3
Output:
Result: 2.0 -
Multiply: Multiplies two numbers.
multiply 3 3
Output:
Result: 9.0 -
Divide: Divides the first number by the second.
divide 10 2
Output:
Result: 5.0 -
Modulo: Computes the remainder of dividing the first number by the second.
modulo 7 2
Output:
Result: 1.0 -
Store: Stores the last result in memory.
store
Output:
Stored value: 5.0 -
Retrieve: Retrieves the stored value.
retrieve
Output:
Retrieved value: 5.0 -
Clear: Clears the stored value.
clear
Output:
Stored value cleared. -
Exit: Exits the calculator.
exitOutput:
Exiting the calculator.
Welcome to the Unsecure Calculator CLI!
Type 'exit' to quit.
> add 5 10
Result: 15.0
> store
Stored value: 15.0
> retrieve
Retrieved value: 15.0
> subtract 20 5
Result: 15.0
> multiply 3 5
Result: 15.0
> divide 15 3
Result: 5.0
> clear
Stored value cleared.
> exit
Exiting the calculator.
- The program uses floating-point arithmetic, so results are displayed as floating-point numbers.