From d6f9b196af57c1585af5077f961f747001759d0c Mon Sep 17 00:00:00 2001 From: Dina Haia Kozia Date: Sun, 30 Nov 2025 19:47:29 +0200 Subject: [PATCH 1/3] Updatetd index.html, style.css and added script.js --- index.html | 4 +-- script.js | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ style.css | 1 + 3 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 script.js diff --git a/index.html b/index.html index 935c09e..4ae638a 100644 --- a/index.html +++ b/index.html @@ -28,10 +28,10 @@
- +
diff --git a/script.js b/script.js new file mode 100644 index 0000000..985a512 --- /dev/null +++ b/script.js @@ -0,0 +1,74 @@ +let display=document.querySelector('.display') +let x,y; +let result; +let operator; + +let plus = document.getElementById('add') +let subtract = document.getElementById('subtract') +let multiply = document.getElementById('multiply') +let divide = document.getElementById('divide') + +plus.addEventListener('click', function(){ + operator='+'; + display.textContent='+'; +}) +subtract.addEventListener('click', function(){ + operator='-'; + display.textContent='-'; +}) +multiply.addEventListener('click', function(){ + operator='*'; + display.textContent='*'; +}) +divide.addEventListener('click', function(){ + operator='/'; + display.textContent='/'; +}) + +let equal = document.querySelector('#equal') + +let num = document.querySelectorAll('.number').forEach(btn=>{ + btn.addEventListener('click', function(){ + if(!operator){ + x=Number(btn.textContent); + display.textContent=btn.textContent; + } + else{ + y=Number(btn.textContent); + display.textContent=btn.textContent; + } + }) +}) + + +equal.addEventListener('click', function(){ + if(operator=='+'){ + result=x+y; + display.textContent=result; + } + if(operator=='-'){ + result = x-y; + display.textContent=result; + } + if(operator=='*'){ + result=x*y; + display.textContent=result; + } + if(operator=='/'){ + result=x/y; + display.textContent=result; + } + operator=''; + x=result; + +}) + +let clear = document.getElementById('clear') +clear.addEventListener('click', function(){ + x=0; + y=0; + operator=''; + display.textContent="" +}) + + diff --git a/style.css b/style.css index e8aee0c..8cef3c3 100644 --- a/style.css +++ b/style.css @@ -45,6 +45,7 @@ body { text-align: right; margin-bottom: 10px; overflow-x: auto; + height: 95px; } .buttons { From 033fd06d584e7adc82333ca38f85c624f9ab3c7d Mon Sep 17 00:00:00 2001 From: Dina Haia Kozia Date: Sun, 7 Dec 2025 13:42:08 +0200 Subject: [PATCH 2/3] Updated HTML and css files and added js file --- calculator_ex_2025 | 1 + 1 file changed, 1 insertion(+) create mode 160000 calculator_ex_2025 diff --git a/calculator_ex_2025 b/calculator_ex_2025 new file mode 160000 index 0000000..c015871 --- /dev/null +++ b/calculator_ex_2025 @@ -0,0 +1 @@ +Subproject commit c015871a5915f882465eda2fd567e03e7bcfeda5 From 553d86e59e71789c90f7ec866a3242ef72cfce2e Mon Sep 17 00:00:00 2001 From: Dina Haia Kozia Date: Sun, 7 Dec 2025 13:53:44 +0200 Subject: [PATCH 3/3] Updated HTML and css files and added js file --- style.css | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/style.css b/style.css index 8cef3c3..3abeff1 100644 --- a/style.css +++ b/style.css @@ -82,7 +82,6 @@ button:active { transform: translateY(0); } -/* Operations Row Styling */ .operations button { background-color: var(--op-bg); color: var(--op-color); @@ -93,14 +92,13 @@ button:active { filter: brightness(110%); } -/* Last Row Styling */ .last-row button { - background-color: #10b981; /* Green for equals/action */ + background-color: #10b981; color: white; } .last-row button:first-child { - background-color: #ef4444; /* Red for Clear */ + background-color: #ef4444; } .last-row button:nth-child(2) {