-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice9-10.html
More file actions
73 lines (69 loc) · 2.16 KB
/
practice9-10.html
File metadata and controls
73 lines (69 loc) · 2.16 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>계산기 만들기</title>
<style>
input{
width: 99%;
}
.calculator {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 10px;
width: 100%;
}
button{
width: 100px;
}
</style>
<script>
function button(c){
let input = document.getElementById('text');
if(c=="="){
input.value = eval(input.value);
}
else if(c=="ce"||c=="c"){
input.value="0";
}
else if(c=="back"){
input.value=input.value.slice(0,-1);
}
else if(c!="none"){
if(input.value=='0'){
input.value='';
}
input.value+=c;
}
}
</script>
</head>
<body>
<h2>계산기 만들기</h2>
<hr>
<input id="text" type="text" value="0" onclick="this.value=''"><br><br>
<div class="calculator">
<button onclick="button('back')">BACK</button>
<button onclick="button('ce')">CE</button>
<button onclick="button('c')">C</button>
<button onclick="button('=')">=</button>
<button onclick="button('7')">7</button>
<button onclick="button('8')">8</button>
<button onclick="button('9')">9</button>
<button onclick="button('/')">/</button>
<button onclick="button('4')">4</button>
<button onclick="button('5')">5</button>
<button onclick="button('6')">6</button>
<button onclick="button('*')">*</button>
<button onclick="button('1')">1</button>
<button onclick="button('2')">2</button>
<button onclick="button('3')">3</button>
<button onclick="button('-')">-</button>
<button onclick="button('0')">0</button>
<button onclick="button('+')">+</button>
<button onclick="button('none')">NONE</button>
<button onclick="button('none')">NONE</button>
</div>
</body>
</html>