-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculadora .html
79 lines (58 loc) · 2.15 KB
/
Calculadora .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
<!doctype html>
<html lang="pt-br">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Logica da programação em Javascript</title>
<link rel="stylesheet" type="text/css" href="estilo.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
</head>
<body>
<div class="rectangle">
<h3> Lógica com Javascript </h3>
<h1> Mini Calculadora </h1>
<section class="button">
<div class="btn-group" role="group" aria-label="Basic example">
<button onclick= "calcular('+')">+</button>
<button onclick= "calcular('-')">-</button>
<button onclick= "calcular('*')">*</button>
<button onclick= "calcular('/')">/</button>
</div>
<h3> Resultado = </h3>
<div id="output"> </div>
</section>
</div>
<footer>
<p>Feito por Paloma Rossi, 2023 </p>
<p> Foto de cottonbro studio: https://www.pexels.com/pt-br/foto/pintura-abstrata-em-preto-e-branco-3826430/ </p>
</footer>
<script>
var n1 = prompt ('Digite 1 número');
n1 = parseFloat(n1);
escreve();
function escreve (){
var output = document.querySelector('#output');
output.innerHTML = n1;
}
function calcular (simbolo){
var n = prompt('Digite outro número');
n=parseFloat(n);
switch(simbolo){
case '+':
n1 +=n;
break;
case '-':
n1 -=n;
break;
case '*':
n1 *=n;
break;
case '/':
n1 /=n;
break;
}
escreve();
}
</script>
</body>
</html>