-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathaula04.02_exercicio.html
More file actions
58 lines (44 loc) · 1.54 KB
/
aula04.02_exercicio.html
File metadata and controls
58 lines (44 loc) · 1.54 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
<!doctype html>
<html>
<head>
<title>Logica de Programação Javascript</title>
<meta charset="utf-8">
</head>
<body>
<h1>Lógica de programação com Javascript</h1>
<button onclick="calcular('+')">+</button>
<button onclick="calcular('-')">-</button>
<button onclick="calcular('*')">*</button>
<button onclick="calcular('/')">/</button>
<div id="output"></div>
<script>
var n1 = prompt('digite um numero');
n1 = parseFloat(n1);
escreve();
function escreve(){
var output = document.querySelector('#output');
output.innerHTML = n1;
}
function calcular(simbolo){
var n = prompt('digite outro numero');
n = parseFloat(n);
//n1 = n1 + n;
//n1 += n;
switch(simbolo){
case '+':
n1 += n;
break;
case '-':
n1 -= n;
break;
case '*':
n1 *= n;
break;
case '/':
n1 /= n;
}
escreve();
}
</script>
</body>
</html>