diff --git a/index.js b/index.js index 8b13789..087d850 100644 --- a/index.js +++ b/index.js @@ -1 +1,47 @@ +// var userInput = readline(); +// print("User input: " + userInput); + +const readline = require('readline'); + +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout +}); + +rl.question("Enter first number ", (num1) => { + rl.question("Enter second number ", (num2) => { + rl.question("Enter operation (+, -, /, *, <, >, =) ", (operator) => { + let numOne = parseInt(num1) + let numTwo = parseInt(num2) + if(operator === "+") { + console.log((numOne) + (numTwo)) + } else if(operator === "-") { + console.log((numOne) - (numTwo)) + } else if(operator === "/") { + console.log((numOne) / (numTwo)) + } else if(operator === "*") { + console.log((numOne) * (numTwo)) + } else if (operator === ">" && numOne > numTwo){ + console.log(`True! ${numOne} is greater than ${numTwo}`) + } else if (operator === ">" && numOne < numTwo){ + console.log(`False! ${numOne} is less than ${numTwo}`) + } else if (operator === "<" && numOne < numTwo){ + console.log(`True! ${numOne} is less than ${numTwo}`) + } else if (operator === "<" && numOne > numTwo){ + console.log(`False! ${numOne} is greater than ${numTwo}`) + } else if ((operator === "<" && numOne === numTwo) || + (operator === "<" && numOne === numTwo)) { + console.log(`False! ${numOne} is equal to ${numTwo}`) + } else if (operator === "=" && numOne === numTwo){ + console.log(`True! ${numOne} is equal to ${numTwo}`) + } else if (operator === "=" && numOne !== numTwo){ + console.log(`False! ${numOne} is not equal to ${numTwo}`) + } else { + console.log("Syntax errrrrrrrror!!!!") + } + return rl.close(); + }) + }) +}) + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..48e341a --- /dev/null +++ b/package-lock.json @@ -0,0 +1,3 @@ +{ + "lockfileVersion": 1 +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..08d14c7 --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "aca-node", + "version": "1.0.0", + "description": "The purpose of this project is to demonstrate that node.js is nothing special. Anyone can create a program that interprets input as code, processes it accordingly and then outputs something.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/tomsonkan/aca-node.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/tomsonkan/aca-node/issues" + }, + "homepage": "https://github.com/tomsonkan/aca-node#readme" +}