-
Lenguaje
Pascal
-
Descripción
Lea edad, estado civil (1:soltero, 2:casado), estatura y sexo (1:hombre, 2:mujer) de 500 personas. Calcular e imprimir: cuántas personas cumplen simultaneamente ser mayor de edad, soltero, hombre y alto (estatura>1.70), el porcentaje de esas personas con respecto a total de personas (500) y el promedio de edad y el promedio estatura de esas personas.
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
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
program PromediosDe500Personas;
uses crt;
var estado_civil, i, personas, sexo : integer;
var edad, estatura, porcentaje, promedio_edad, promedio_estatura : real;
begin
personas := 0;
porcentaje := 0;
promedio_edad := 0;
promedio_estatura := 0;
for i:=1 to 500 do
begin
writeln ('PROCESO ', i);
write ('Ingresa el valor de edad: ');
readln (edad);
write ('Ingresa el valor de estatura: ');
readln (estatura);
writeln ('Selecciona el valor de estado civil.');
writeln (' 1.- soltero');
writeln (' 2.- casado');
write (' : ');
repeat
readln (estado_civil);
if (estado_civil<1) or (estado_civil>2) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (estado_civil>=1) and (estado_civil<=2);
writeln ('Selecciona el valor de sexo.');
writeln (' 1.- hombre');
writeln (' 2.- mujer');
write (' : ');
repeat
readln (sexo);
if (sexo<1) or (sexo>2) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (sexo>=1) and (sexo<=2);
if (edad>=18) and (estado_civil=1) and (sexo=1) and (estatura>1.7) then
begin
personas := personas+1;
promedio_edad := promedio_edad+edad;
promedio_estatura := promedio_estatura+estatura;
end;
writeln;
end;
porcentaje := 100.0*personas/500;
if personas = 0 then
promedio_edad := 0
else
promedio_edad := promedio_edad/personas;
if personas = 0 then
promedio_estatura := 0
else
promedio_estatura := promedio_estatura/personas;
writeln ('Valor de personas: ', personas);
writeln ('Valor de porcentaje: ', porcentaje:0:6);
writeln ('Valor de promedio edad: ', promedio_edad:0:6);
writeln ('Valor de promedio estatura: ', promedio_estatura:0:6);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var estado_civil, i, personas, sexo : integer;
var edad, estatura, porcentaje, promedio_edad, promedio_estatura : real;
begin
personas := 0;
porcentaje := 0;
promedio_edad := 0;
promedio_estatura := 0;
for i:=1 to 500 do
begin
writeln ('PROCESO ', i);
write ('Ingresa el valor de edad: ');
readln (edad);
write ('Ingresa el valor de estatura: ');
readln (estatura);
writeln ('Selecciona el valor de estado civil.');
writeln (' 1.- soltero');
writeln (' 2.- casado');
write (' : ');
repeat
readln (estado_civil);
if (estado_civil<1) or (estado_civil>2) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (estado_civil>=1) and (estado_civil<=2);
writeln ('Selecciona el valor de sexo.');
writeln (' 1.- hombre');
writeln (' 2.- mujer');
write (' : ');
repeat
readln (sexo);
if (sexo<1) or (sexo>2) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (sexo>=1) and (sexo<=2);
if (edad>=18) and (estado_civil=1) and (sexo=1) and (estatura>1.7) then
begin
personas := personas+1;
promedio_edad := promedio_edad+edad;
promedio_estatura := promedio_estatura+estatura;
end;
writeln;
end;
porcentaje := 100.0*personas/500;
if personas = 0 then
promedio_edad := 0
else
promedio_edad := promedio_edad/personas;
if personas = 0 then
promedio_estatura := 0
else
promedio_estatura := promedio_estatura/personas;
writeln ('Valor de personas: ', personas);
writeln ('Valor de porcentaje: ', porcentaje:0:6);
writeln ('Valor de promedio edad: ', promedio_edad:0:6);
writeln ('Valor de promedio estatura: ', promedio_estatura:0:6);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.