-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculator.html
More file actions
79 lines (76 loc) · 2.17 KB
/
calculator.html
File metadata and controls
79 lines (76 loc) · 2.17 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Assignment 1</title>
<style type="text/css">
.button{
width: 40px;
height: 30px;
background: orange;
}
.display input
{
position: relative;
left: 4px;
top: 4px;
height: 35px;
/*width: 70px;*/
color: black;
/*text-align: right;*/
font-size: 15px;
}
</style>
<script type="text/javascript">
function c(val)
{
document.getElementById("display").value = val;
}
function math(val)
{
document.getElementById("display").value += val;
}
function e()
{
c(eval(document.getElementById("display").value))
}
</script>
</head>
<body>
<div align="center">
<div class ="display">
<input type="text" size="15" id="display" style="margin-left:7px" readonly>
<div class="keys">
<p>
<input type="button" class="button" value="(" onclick='math("(")'>
<input type="button" class="button" value=")" onclick='math(")")'>
<input type="button" class="button" value="/" onclick='math("/")'>
<input type="button" class="button" value="=" onclick='e()'>
</p>
<p>
<input type="button" class="button" value="7" onclick='math("7")'>
<input type="button" class="button" value="8" onclick='math("8")'>
<input type="button" class="button" value="9" onclick='math("9")'>
<input type="button" class="button" value="*" onclick='math("*")'>
</p>
<p>
<input type="button" class="button" value="4" onclick='math("4")'>
<input type="button" class="button" value="5" onclick='math("5")'>
<input type="button" class="button" value="6" onclick='math("6")'>
<input type="button" class="button" value="-" onclick='math("-")'>
</p>
<p>
<input type="button" class="button" value="1" onclick='math("1")'>
<input type="button" class="button" value="2" onclick='math("2")'>
<input type="button" class="button" value="3" onclick='math("3")'>
<input type="button" class="button" value="+" onclick='math("+")'>
</p>
<p>
<input type="button" class="button" value="0" onclick='math("0")'>
<input type="button" class="button" value="." onclick='math(".")'>
<input type="button" class="button" value="C" onclick='c("")'>
</p>
</div>
</div>
</div>
</body>
</html>