From 6e48ba8ccaa6aa9f13cbeb89f1c3bd4aeee7a322 Mon Sep 17 00:00:00 2001 From: geetikaaaaa Date: Mon, 30 Aug 2021 20:19:18 +0530 Subject: [PATCH] Calculator --- calculator.css | 38 ++++++++++++++++++++++++++++++++++ calculator.js | 35 ++++++++++++++++++++++++++++++++ index.html | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 calculator.css create mode 100644 calculator.js create mode 100644 index.html diff --git a/calculator.css b/calculator.css new file mode 100644 index 0000000..4e550d2 --- /dev/null +++ b/calculator.css @@ -0,0 +1,38 @@ +.calculator{ + margin-left:30%; + background-color: #e3e5ec; + box-shadow: 0 2px 8px rgba(0,0,0,.16); + width: 500px; + height: 550px; + text-align: center; +} + + + +.header{ + margin-left:40%; +} +.text{ + margin-left:30%; +} +.btn{ + padding: 40px 50px; + background-color: #e3e5ec; + border:#e3e5ec; + font-size: 18px; +} +.btn:hover{ + background-color: rgb(113, 113, 241); +} + +.table{ + margin-top: 5%; +} +.fas{ + color:rgb(99, 99, 250); +} +.fab{ + color:rgb(99, 99, 250); +} + + diff --git a/calculator.js b/calculator.js new file mode 100644 index 0000000..17ac7f9 --- /dev/null +++ b/calculator.js @@ -0,0 +1,35 @@ +function backspace(){ + document.getElementById("display").value= document.getElementById("display").value.slice(0, - 1); + } + +function clearScreen(){ + document.getElementById("display").value = ""; + } + + +function onScreen(value) { + if(document.getElementById("display").value.length>30) + alert("Cannot enter more than 30 digits"); + else + document.getElementById("display").value += value; +} + + +function operations() { + let p = document.getElementById("display").value; + let q = eval(p); + document.getElementById("display").value = q; + if(document.getElementById("display").value.length>10) + alert("Calulation limit exceeded"); + else + document.getElementById("display").value = q; + } +function percent(){ + let p = document.getElementById("display").value; + let q = p/100; + document.getElementById("display").value = q; +} + + + + diff --git a/index.html b/index.html new file mode 100644 index 0000000..e80992b --- /dev/null +++ b/index.html @@ -0,0 +1,55 @@ + + + + + + + Document + + + + +
+

Calculator

+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + \ No newline at end of file