-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice9-10.html
More file actions
80 lines (80 loc) · 3.07 KB
/
practice9-10.html
File metadata and controls
80 lines (80 loc) · 3.07 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
80
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>실습문제 9-10</title>
<style>
table {
text-align: center;
border: hidden;
}
td {
width: 100px;
}
input {
width: 50%;
}
</style>
<script>
var expression="";
function number(text)
{
expression += text;
document.getElementById("win").value = expression;
}
function compute()
{
document.getElementById("win").value = eval(expression);
}
function evalclear()
{
document.getElementById("win").value = "0";
expression = "";
}
function Backspace() {
length = document.getElementById("win").value.length;
document.getElementById("win").value = document.getElementById("win").value.substring(0, length - 1);
expression = document.getElementById("win").value.toString();
document.getElementById("win").value = expression;
}
</script>
</head>
<body>
<h3>계산기 만들기</h3>
<hr>
<input type="text" id="win" value="0" style="width:99%">
<table border=0 style="width:100%; height:100%;">
<tr colspan=4 >
<td><input type="button" value="Back" onclick="Backspace()"></td>
<td><input type="button" value="CE" onclick="evalclear()"></td>
<td><input type="button" value="C" onclick="evalclear()"></td>
<td><input type="button" value="=" onclick="compute()"></td>
</tr>
<tr>
<td><input type="button" value="7" onclick="number('7')"></td>
<td><input type="button" value="8" onclick="number('8')"></td>
<td><input type="button" value="9" onclick="number('9')"></td>
<td><input type="button" value="/" onclick="number('/')"></td>
</tr>
<tr>
<td><input type="button" value="4" onclick="number('4')"></td>
<td><input type="button" value="5" onclick="number('5')"></td>
<td><input type="button" value="6" onclick="number('6')"></td>
<td><input type="button" value="*" onclick="number('*')"></td>
</tr>
<tr>
<td><input type="button" value="1" onclick="number('1')"></td>
<td><input type="button" value="2" onclick="number('2')"></td>
<td><input type="button" value="3" onclick="number('3')"></td>
<td><input type="button" value="-" onclick="number('-')"></td>
</tr>
<tr>
<td><input type="button" value="0" onclick="number('0')"></td>
<td><input type="button" value="+" onclick="number('+')"></td>
<td><input type="button" value="NONE"></td>
<td><input type="button" value="NONE"></td>
</tr>
</table>
</body>
</html>