This is a simple calculator that can perform addition, subtraction, multiplication, and division.
git clone https://github.com/BalliAsghar/Calculator
cd Calculator
npm install
Run the following command to open the Calculator in interactive mode
node index.js
Note: You can also use npm install -g
to install the package globally and then use calc
command to run the program from anywhere.
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.
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
node index.js add 10 5
- 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 43
is valid, butadd 25,43
is not.