-
Notifications
You must be signed in to change notification settings - Fork 0
/
reto1plus.html
41 lines (40 loc) · 1.5 KB
/
reto1plus.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
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Calcular</title>
</head>
<body>
<h1>Haz varias operaciones con dos numeros</h1>
<p>En esta lista aparecen los numeros que has dado haciendo varias operaciones</p>
<input id="num1" value="8" ><br>
<input id="num2" value="6" >
<button type="button" onclick="myFunction()">Calcular</button>
<p id="sumando1"></p>
<p id="sumando2"></p>
<p id="sumando3"></p>
<p id="sumando4"></p>
<p id="sumando5"></p>
<script>
function myFunction() {
var x,y,suma,text;
x = document.getElementById("num1").value;
y = document.getElementById("num2").value;
suma=parseFloat(x)+parseFloat(y);
resta=parseFloat(x)-parseFloat(y);
multiplica=parseFloat(x)*parseFloat(y);
didision=parseFloat(x)/parseFloat(y);
elevado=Math.pow(parseFloat(x),parseFloat(y));
text1= suma;
text2= resta;
text3= multiplica;
text4= didision;
text5= elevado;
document.getElementById("sumando1").innerHTML = "El resultado de sumar "+x+"y"+y+" es: "+text1;
document.getElementById("sumando2").innerHTML = "El resultado de restar"+x+"y"+y+" es: "+text2;
document.getElementById("sumando3").innerHTML = "El resultado de multiplicar "+x+"y"+y+" es: "+text3;
document.getElementById("sumando4").innerHTML = "El resultado de dividir "+x+"y"+y+" es: "+text4;
document.getElementById("sumando5").innerHTML = "El resultado de elevar "+x+"y"+y+" es: "+text5; }
</script>
</body>
</html>