From a88bab986497899dcf60e297436105930501bac1 Mon Sep 17 00:00:00 2001 From: Astha Nitnaware Date: Thu, 9 Apr 2026 01:31:10 +0530 Subject: [PATCH] Added calculator app --- calculator-app/index.html | 39 +++++++++++++++++++++++++++++++++++++++ calculator-app/script.js | 21 +++++++++++++++++++++ calculator-app/style.css | 15 +++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 calculator-app/index.html create mode 100644 calculator-app/script.js create mode 100644 calculator-app/style.css diff --git a/calculator-app/index.html b/calculator-app/index.html new file mode 100644 index 00000000..234b5da9 --- /dev/null +++ b/calculator-app/index.html @@ -0,0 +1,39 @@ + + + + Calculator + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
+
+ + + + \ No newline at end of file diff --git a/calculator-app/script.js b/calculator-app/script.js new file mode 100644 index 00000000..3b550258 --- /dev/null +++ b/calculator-app/script.js @@ -0,0 +1,21 @@ +let display = document.getElementById("display"); + +function press(val) { + display.value += val; +} + +function calculate() { + try { + display.value = eval(display.value); // (ok for practice) + } catch { + display.value = "ERR"; + } +} + +function clearAll() { + display.value = ""; +} + +function clearLast() { + display.value = display.value.slice(0, -1); +} \ No newline at end of file diff --git a/calculator-app/style.css b/calculator-app/style.css new file mode 100644 index 00000000..4399b489 --- /dev/null +++ b/calculator-app/style.css @@ -0,0 +1,15 @@ +body { + font-family: Arial; + text-align: center; +} + +.calculator { + width: 200px; + margin: auto; +} + +button { + width: 40px; + height: 40px; + margin: 2px; +} \ No newline at end of file