From a8e55d7d5a327fa3d08afb10af036ff860d9343d Mon Sep 17 00:00:00 2001 From: Gokulakrishnan5060 Date: Sat, 25 Nov 2023 15:27:40 +0530 Subject: [PATCH] simple working calculator updated --- projects/calculator/favicon.png | Bin 0 -> 3089 bytes projects/calculator/index.html | 52 ++++++++++++++++++++ projects/calculator/script.js | 22 +++++++++ projects/calculator/style.css | 84 ++++++++++++++++++++++++++++++++ 4 files changed, 158 insertions(+) create mode 100644 projects/calculator/favicon.png create mode 100644 projects/calculator/index.html create mode 100644 projects/calculator/script.js create mode 100644 projects/calculator/style.css diff --git a/projects/calculator/favicon.png b/projects/calculator/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..32ab6075dbd13abb6d06c60d1ed64e97adac6bbf GIT binary patch literal 3089 zcmV+s4DR!ZP)v&N) zBS;Du&3I9{$V>8jD0(AV{sR{-@KSUdFUsYi7C;E5iOMg$D37z*YE`*fHxbtZi9!AEfL;9)p>_AKa`3l}cJkt6?xPe1(}=FTgD4w+qCy;_p@o2}6b zXEbn*6(sqvI?#t7$%c)aw!+n`SHbA)*|QgV_8#Eu%~hCha7GfB7nMpJoM?%G1q+wL zqU3Uh2+P+z7YDa_%Rg`WAkLjT4|~ch;GOO7!$00Ag}<+S z^R~9b-~Ui+k@r@71+5bvz9zDKRuq+HoSqRx?H*MbLb>P+2SJ)f=#Gv628Ql`B zwx-ag?ZfbBPIt)Z*yFag4I8#VUHImkZ$VaCU7M4YA9R~xn?<>kI`3du_Qref?|}4- z&d?&RJxrfb44-}WITPH-Y~8xuX*nfN;q*t3I|NbLhXY7S&4$aDFMAB~%9SfHYxV-L zN411`^A|%^RTYF2gNKZ)NxB3f)LYHeM7ZEGm1NGcp=2McEIl4dmtP+cOiBi}D)0@r1UinoA+{Tom`mACE#fGw_LFs=$Xh{m|nMUXoAajZdC3!(&kI zzPE#g<#6>}XK!Vq<}Rd225riOeRxM zO_UI#~x~!ewot)xc{joFqR+D6MPMILx(*B)`-}k3u|%{IoXlv*K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Qm#nu!oHU-SQ^#9Xm18inqV#f&M%QbEKY@hor_USvw7bmzn)g;8iU;0EkPc@=>hDKD@gJ=ylMAi`;a$Qt$}7O+QAP;{srMcW#t*x9PEWz^E`fsZShor zb=Aj^m*j1D)2V4W9)rRVH~gtW)_uk3-Oj43udt<2=dQis;>C*|zaKGjtlE&{7{_t- zIK3cP7V=+wC?qp#ZD|cGrB6z6yHSfJ7Nl|uAZ}5^b zNcG}3SGz9mRZ!Gd{_-kIWU!Si&d=CgMUPZfRl$ahTUfS?2^F>v(hAFJS8%m&Auq~H zIbGs#)E7jh0ta!kR(4nfnNz%wbu_`{NLofG=$ro}tK9~=@zwZSFxHVS2Bg%ufLpX5q+MZ2e8gxLwbU`Qw!4Cy$r%-sDd8@`BLCUhn^nV(V%Sg`cUSak z$&O5xP`Zx|mqLQ5EVkL2H{!y9CQYIm@}fM6m*o9{t|behwV!xNUZ9)i&w)S`qXk}) zd+?$%QIO + + + + + + + + + + + Gokulakrishnan Calculator + + + + + + + + +
+

G Calculator

+
+ +
+
+
+ + + + +
+
+ + + + + + + + + + + + + +
+
+
+ + + diff --git a/projects/calculator/script.js b/projects/calculator/script.js new file mode 100644 index 0000000..67a5a50 --- /dev/null +++ b/projects/calculator/script.js @@ -0,0 +1,22 @@ +let expression = ''; + +function appendToDisplay(value) { + expression += value; + document.getElementById('display').value = expression; +} + +function calculate() { + try { + const result = eval(expression); + document.getElementById('display').value = result; + expression = ''; + } catch (error) { + document.getElementById('display').value = 'Error'; + expression = ''; + } +} + +function clearDisplay() { + expression = ''; + document.getElementById('display').value = ''; +} diff --git a/projects/calculator/style.css b/projects/calculator/style.css new file mode 100644 index 0000000..fd600d4 --- /dev/null +++ b/projects/calculator/style.css @@ -0,0 +1,84 @@ +body { + margin: 0; + padding: 0; + font-family: Arial, sans-serif; + background: url("https://images.unsplash.com/photo-1625225233840-695456021cde?auto=format&fit=crop&q=80&w=1000&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8Y2FsY3VsYXRlfGVufDB8fDB8fHww"); + background-size: contain; + background-position: center; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; +} + +.calculator { + background-color: rgba(255, 255, 255, 0.8); + border-radius: 10px; + padding: 20px; + text-align: center; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); + max-width: 300px; + margin: 0 auto; +} + +h1 { + margin-top: 0; +} + +.display { + margin-bottom: 20px; +} + +input[type="text"] { + width: 100%; + padding: 10px; + font-size: 1.5em; +} + +.keys { + display: flex; + flex-direction: column; + align-items: center; +} + +button { + width: 60px; + height: 60px; + margin: 5px; + font-size: 1.2em; + border-radius: 5px; + border: none; + outline: none; + cursor: pointer; + transition: all 0.2s ease-in-out; +} + +button:hover { + transform: scale(1.1); +} + +.operator { + background-color: #ff847c; + color: white; +} + +.number { + background-color: #70c1b3; + color: white; +} + +.clear { + background-color: #b8b8b8; + color: white; +} + +.calculate { + background-color: #f0c987; + color: white; +} + +@media only screen and (max-width: 600px) { + .calculator { + max-width: 90%; + } +}