-
Lenguaje
Pascal
-
Descripción
Solicite la edad y el sexo de un conjunto de n personas y determine:
a) Cuantas mujeres son mayores de edad.
b) Cuantos hombres son mayores de 60 años.
c) Cuantas mujeres son niñas (menos de 13 años).
d) Cuantos hombres son adolescentes (entre 13 y 17 años).
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
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
program EdadYGenero;
uses crt;
var a, b, c, d, edad : integer;
var genero, i, n : integer;
begin
a := 0;
b := 0;
c := 0;
d := 0;
write ('Ingresa el valor de n: ');
readln (n);
for i:=1 to n do
begin
writeln ('PROCESO ', i);
write ('Ingresa el valor de edad: ');
readln (edad);
writeln ('Selecciona el valor de genero.');
writeln (' 1.- Mujer');
writeln (' 2.- Hombre');
write (' : ');
repeat
readln (genero);
if (genero<1) or (genero>2) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (genero>=1) and (genero<=2);
if (genero=1) and (edad>=18) then
begin
a := a+1;
end;
if (genero=2) and (edad>60) then
begin
b := b+1;
end;
if (genero=1) and (edad<13) then
begin
c := c+1;
end;
if (genero=2) and (edad>=13) and (edad<18) then
begin
d := d+1;
end;
writeln;
end;
writeln ('Valor de a: ', a);
writeln ('Valor de b: ', b);
writeln ('Valor de c: ', c);
writeln ('Valor de d: ', d);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var a, b, c, d, edad : integer;
var genero, i, n : integer;
begin
a := 0;
b := 0;
c := 0;
d := 0;
write ('Ingresa el valor de n: ');
readln (n);
for i:=1 to n do
begin
writeln ('PROCESO ', i);
write ('Ingresa el valor de edad: ');
readln (edad);
writeln ('Selecciona el valor de genero.');
writeln (' 1.- Mujer');
writeln (' 2.- Hombre');
write (' : ');
repeat
readln (genero);
if (genero<1) or (genero>2) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (genero>=1) and (genero<=2);
if (genero=1) and (edad>=18) then
begin
a := a+1;
end;
if (genero=2) and (edad>60) then
begin
b := b+1;
end;
if (genero=1) and (edad<13) then
begin
c := c+1;
end;
if (genero=2) and (edad>=13) and (edad<18) then
begin
d := d+1;
end;
writeln;
end;
writeln ('Valor de a: ', a);
writeln ('Valor de b: ', b);
writeln ('Valor de c: ', c);
writeln ('Valor de d: ', d);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.