diff --git a/Calculators/Prompt Box Calculator/README.md b/Calculators/Prompt Box Calculator/README.md new file mode 100644 index 000000000..8a6c58c07 --- /dev/null +++ b/Calculators/Prompt Box Calculator/README.md @@ -0,0 +1,18 @@ +# Simple Calculator using JavaScript Operations + +This is a basic calculator application built using JavaScript. It performs standard arithmetic operations such as addition, subtraction, multiplication, and division. + +![ouput](./calc_output.PNG) + +## Features + +- Addition +- Subtraction +- Multiplication +- Division + +## How It Works + +- The calculator logic is implemented using JavaScript. +- Each button click triggers a corresponding function that updates the display with the result of the operation. +- The `eval()` function is used to evaluate the mathematical expression entered by the user. diff --git a/Calculators/Prompt Box Calculator/calc.js b/Calculators/Prompt Box Calculator/calc.js new file mode 100644 index 000000000..154666a0d --- /dev/null +++ b/Calculators/Prompt Box Calculator/calc.js @@ -0,0 +1,24 @@ +let op = prompt("Enter operation (+, -, *, /)"); + + if (op != "+" && op != "-" && op != "/" && op != "*") { + document.write("Invalid operation (please try again!)"); + } else { + let firstNumber = prompt("Enter first number"); + let secondNumber = prompt("Enter second number"); + + if (op == "+") { + document.write(+firstNumber + +secondNumber); + } else if (op == "-") { + document.write(+firstNumber - +secondNumber); + } else if (op == "*") { + document.write(+firstNumber * +secondNumber); + } else if (op == "/") { + document.write(+firstNumber / +secondNumber); + } + } + + + + + + \ No newline at end of file diff --git a/Calculators/Prompt Box Calculator/calc_output.PNG b/Calculators/Prompt Box Calculator/calc_output.PNG new file mode 100644 index 000000000..b224ed0c2 Binary files /dev/null and b/Calculators/Prompt Box Calculator/calc_output.PNG differ diff --git a/Calculators/Prompt Box Calculator/index.html b/Calculators/Prompt Box Calculator/index.html new file mode 100644 index 000000000..4634b85c9 --- /dev/null +++ b/Calculators/Prompt Box Calculator/index.html @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file