-
Lenguaje
JavaScript
-
Descripción
Digitar 5 números por pantalla y calcular e imprimir, la suma y el promedio de los números digitados.
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Suma y promedio de 5 números</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script>
<html>
<head>
<title>Suma y promedio de 5 números</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script>
function algoritmo()
{
let a, b, c, d, e;
let promedio, suma;
a = parseFloat (document.formulario1.a.value);
b = parseFloat (document.formulario1.b.value);
c = parseFloat (document.formulario1.c.value);
d = parseFloat (document.formulario1.d.value);
e = parseFloat (document.formulario1.e.value);
suma=a+b+c+d+e;
promedio=suma/5;
document.formulario1.promedio.value = promedio;
document.formulario1.suma.value = suma;
}
{
let a, b, c, d, e;
let promedio, suma;
a = parseFloat (document.formulario1.a.value);
b = parseFloat (document.formulario1.b.value);
c = parseFloat (document.formulario1.c.value);
d = parseFloat (document.formulario1.d.value);
e = parseFloat (document.formulario1.e.value);
suma=a+b+c+d+e;
promedio=suma/5;
document.formulario1.promedio.value = promedio;
document.formulario1.suma.value = suma;
}
</script>
</head>
<body>
<form name="formulario1">
<table style="text-align: left; margin-left: auto; margin-right: auto;">
<tbody>
<tr>
<td>
<label for="a">Ingresa el valor de a:</label>
</td>
<td>
<input name="a" required="required" step="0.000001" type="number" />
</td>
</tr>
<tr>
<td>
<label for="b">Ingresa el valor de b:</label>
</td>
<td>
<input name="b" required="required" step="0.000001" type="number" />
</td>
</tr>
<tr>
<td>
<label for="c">Ingresa el valor de c:</label>
</td>
<td>
<input name="c" required="required" step="0.000001" type="number" />
</td>
</tr>
<tr>
<td>
<label for="d">Ingresa el valor de d:</label>
</td>
<td>
<input name="d" required="required" step="0.000001" type="number" />
</td>
</tr>
<tr>
<td>
<label for="e">Ingresa el valor de e:</label>
</td>
<td>
<input name="e" required="required" step="0.000001" type="number" />
</td>
</tr>
<tr align="center">
<td colspan="2" rowspan="1">
<input value="Procesar" type="button" onclick="algoritmo();" />
<input type="reset" />
</td>
</tr>
<tr>
<td>
<label for="promedio">Valor de promedio:</label>
</td>
<td>
<input name="promedio" step="0.000001" type="number" />
</td>
</tr>
<tr>
<td>
<label for="suma">Valor de suma:</label>
</td>
<td>
<input name="suma" step="0.000001" type="number" />
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
</head>
<body>
<form name="formulario1">
<table style="text-align: left; margin-left: auto; margin-right: auto;">
<tbody>
<tr>
<td>
<label for="a">Ingresa el valor de a:</label>
</td>
<td>
<input name="a" required="required" step="0.000001" type="number" />
</td>
</tr>
<tr>
<td>
<label for="b">Ingresa el valor de b:</label>
</td>
<td>
<input name="b" required="required" step="0.000001" type="number" />
</td>
</tr>
<tr>
<td>
<label for="c">Ingresa el valor de c:</label>
</td>
<td>
<input name="c" required="required" step="0.000001" type="number" />
</td>
</tr>
<tr>
<td>
<label for="d">Ingresa el valor de d:</label>
</td>
<td>
<input name="d" required="required" step="0.000001" type="number" />
</td>
</tr>
<tr>
<td>
<label for="e">Ingresa el valor de e:</label>
</td>
<td>
<input name="e" required="required" step="0.000001" type="number" />
</td>
</tr>
<tr align="center">
<td colspan="2" rowspan="1">
<input value="Procesar" type="button" onclick="algoritmo();" />
<input type="reset" />
</td>
</tr>
<tr>
<td>
<label for="promedio">Valor de promedio:</label>
</td>
<td>
<input name="promedio" step="0.000001" type="number" />
</td>
</tr>
<tr>
<td>
<label for="suma">Valor de suma:</label>
</td>
<td>
<input name="suma" step="0.000001" type="number" />
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>