-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator.html
166 lines (156 loc) · 8.71 KB
/
calculator.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<html>
<head>
<title>My Calculator</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<link rel="shortcut icon" type="image/jpeg" href="calc.PNG">
<style>
.full-width{
width: 100%;
}
</style>
</head>
<body>
<div class="container bg-dark mt-5">
<div class="row">
<div class="col-lg-3"></div>
<div class="col-lg-6 text-center shadow">
<div class="row mt-3 py-3 btn btn-primary full-width">
<div class="col">
<strong>Calculator</strong>
</div>
</div>
<div class="row">
<div class="col my-3">
<textarea class="full-width p-3 text-right" readonly id="history" rows="4"></textarea>
</div>
</div>
<div class="row">
<div class="col-10">
<div class="row">
<div class="col mb-2">
<input type="text" class="full-width" id="result">
</div>
</div>
<div class="row">
<div class="col-4">
<div class="row">
<div class="col mb-2">
<input type="button" value="1" class="full-width" onclick="dis('1')">
</div>
</div>
<div class="row">
<div class="col mb-2">
<input type="button" value="4" class="full-width" onclick="dis('4')">
</div>
</div>
<div class="row">
<div class="col mb-2">
<input type="button" value="7" class="full-width" onclick="dis('7')">
</div>
</div>
<div class="row">
<div class="col mb-2">
<input type="button" value="." class="full-width" onclick="dis('.')">
</div>
</div>
</div>
<div class="col-4">
<div class="row">
<div class="col mb-2">
<input type="button" value="2" class="full-width" onclick="dis('2')">
</div>
</div>
<div class="row">
<div class="col mb-2">
<input type="button" value="4" class="full-width" onclick="dis('4')">
</div>
</div>
<div class="row">
<div class="col mb-2">
<input type="button" value="8" class="full-width" onclick="dis('8')">
</div>
</div>
<div class="row">
<div class="col mb-2">
<input type="button" value="0" class="full-width" onclick="dis('0')">
</div>
</div>
</div>
<div class="col-4">
<div class="row">
<div class="col mb-2">
<input type="button" value="3" class="full-width" onclick="dis('3')">
</div>
</div>
<div class="row">
<div class="col mb-2">
<input type="button" value="6" class="full-width" onclick="dis('6')">
</div>
</div>
<div class="row">
<div class="col mb-2">
<input type="button" value="9" class="full-width" onclick="dis('9')">
</div>
</div>
<div class="row">
<div class="col mb-2">
<input type="button" value="=" class="full-width" onclick="slv('=')">
</div>
</div>
</div>
</div>
</div>
<div class="col-2">
<div class="row">
<div class="col mb-2">
<input type="button" value="C" class="full-width" onclick="clr()">
</div>
</div>
<div class="row">
<div class="col mb-2">
<input type="button" value="/" class="full-width" onclick="op('/')">
</div>
</div>
<div class="row">
<div class="col mb-2">
<input type="button" value="x" class="full-width" onclick="op('*')">
</div>
</div>
<div class="row">
<div class="col mb-2">
<input type="button" value="-" class="full-width" onclick="op('-')">
</div>
</div>
<div class="row">
<div class="col mb-2">
<input type="button" value="+" class="full-width" onclick="op('+')">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
function clr(){
document.getElementById('result').value = "";
}
function dis(value){
document.getElementById('result').value += value;
}
function op(value){
document.getElementById('result').value += value;
}
function slv(){
var textareaElement = document.getElementById('history');
var x = document.getElementById('result').value;
var y = eval(x);
clr();
textareaElement.value = textareaElement.value + x + '=' + y + '\n';
}
</script>
</body>
</html>