Skip to content

Commit 1cbdd07

Browse files
authored
Merge pull request #843 from saikrishna823/Calculator-saikrishna823
Completed Adding Calculator App
2 parents 4cb9d46 + 15b7158 commit 1cbdd07

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
let inputBtn=document.getElementById("inputBtn")
2+
let buttons=document.querySelectorAll(".button");
3+
const evalButton=document.getElementById("evalButton");
4+
const clearBtn=document.querySelector(".clearBtn");
5+
buttons.forEach((button)=>{
6+
button.onclick=()=>{
7+
inputBtn.value+=button.textContent;
8+
}
9+
})
10+
;
11+
evalButton.onclick=()=>{
12+
inputBtn.value=eval(inputBtn.value);
13+
}
14+
clearBtn.onclick=()=>{
15+
inputBtn.value=" ";
16+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>
5+
Calculator
6+
</title>
7+
</head>
8+
<link href="styles.css" rel="stylesheet">
9+
<body>
10+
<span id="container">
11+
<h1>Calculator</h1>
12+
<div class="input">
13+
<input type="text" id="inputBtn">
14+
<button type="reset" class="clearBtn">C</button>
15+
</div>
16+
<div class="input-buttons">
17+
<div class="button">1</div>
18+
<div class="button">2</div>
19+
<div class="button">3</div>
20+
<div class="button">/</div>
21+
<div class="button">4</div>
22+
<div class="button">5</div>
23+
<div class="button">6</div>
24+
<div class="button">-</div>
25+
<div class="button">7</div>
26+
<div class="button">8</div>
27+
<div class="button">9</div>
28+
<div class="button">+</div>
29+
<div class="button">.</div>
30+
<div class="button">0</div>
31+
<button id="evalButton">=</button>
32+
<div class="button">*</div>
33+
</div>
34+
</span>
35+
<script src="calculator.js"></script>
36+
</body>
37+
</html>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
*,body,html{
2+
box-sizing: border-box;
3+
margin:0px;
4+
5+
}
6+
h1{
7+
margin:5px;
8+
color:brown;
9+
text-transform: uppercase;
10+
text-decoration:solid;
11+
12+
}
13+
body{
14+
background-color: beige;
15+
}
16+
#container{
17+
display: flex;
18+
justify-content: center;
19+
align-items: center;
20+
flex-direction: column;
21+
margin:100px;
22+
}
23+
.input-buttons{
24+
margin:10px;
25+
display: grid;
26+
grid-template-columns:repeat(4,55px);
27+
grid-template-rows:repeat(4,35px);
28+
gap:10px;
29+
30+
}
31+
.button{
32+
padding:5px;
33+
background-color: rgb(77, 10, 139);
34+
text-align: center;
35+
color: white;
36+
border-radius: 10px;
37+
font-size: x-large;
38+
}
39+
#evalButton{
40+
background-color:rgb(239, 14, 194);
41+
text-align: center;
42+
color: white;
43+
border-color:greenyellow;
44+
border-radius: 10px;
45+
font-size:x-large;
46+
47+
}
48+
#evalButton:hover,focus,active{
49+
outline: none;
50+
}
51+
#inputBtn{
52+
border-radius:4px;
53+
height:28px;
54+
width:220px;
55+
}
56+
.clearBtn{
57+
border-radius:3px;
58+
padding:2px;
59+
text-align: center;
60+
font-size: larger;
61+
color: white;
62+
background-color:rgb(239, 14, 194);
63+
}

0 commit comments

Comments
 (0)