A Simple Calculator
This is a simple calculator that can perform addition, subtraction, multiplication, and division.
How to use
Clone the repository
Move to the directory
Install the dependencies
Usage
Run the following command to open the Calculator in interactive mode
Note: You can also use npm install -g to install the package globally and then use calc command to run the program from anywhere.
Calculator in interactive mode
In interactive mode, you can perform multiple operations one after another. To exit the interactive mode, press Ctrl + C. or select Exit
Note: First type the first number, then select the operation, and then type the second number. The result will be displayed on the screen. then the result will be used as the first number for the next operation.
Command Mode
Available Commands
add- Adds two numbers or moresub- Subtracts two numbers or moremul- Multiplies two numbers or morediv- Divides two numbers or morehelp- Displays the help menu
Command Usage
Limitations
- The calculator can only perform one operation at a time. means, you can't add and subtract at the same time. e.g.
node index.js add 10 5 sub 2 1 - The calculator can only accept numbers with spaces between them. For example,
add 25 43is valid, butadd 25,43is not.