diff --git a/mathematical_operations/js/math_operations.js b/mathematical_operations/js/math_operations.js new file mode 100644 index 000000000..cecfd7f9a --- /dev/null +++ b/mathematical_operations/js/math_operations.js @@ -0,0 +1,19 @@ +//math_operations.js --- using node.js readline-sync module +//(must install the module to run --- package.json included) +const rlSync = require('readline-sync'); + +const a = parseInt(rlSync.question("First integer: ")); +const b = parseInt(rlSync.question("Second integer: ")); + +const sum = a + b; +const product = a * b; +const difference = a - b; +const quotient = a / b; +const remainder = a % b; + + +console.log("The sum %d + %d = %d", a, b, sum); +console.log("The difference %d - %d = %d", a, b, difference); +console.log("The product %d * %d = %d", a, b, product); +console.log("The quotient %d / %d = %d", a, b, quotient); +console.log("The remainder of the division %d / %d = %d", a, b, remainder); diff --git a/package.json b/package.json index 57a023dd6..faf2dc1f7 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "dependencies": {}, "devDependencies": { "@types/node": "^8.0.37", + "readline-sync": "^1.4.7", "ts-node": "^3.3.0", "typescript": "^2.5.3" }