-
Lenguaje
Pascal
-
Descripción
Capture el nombre y apellido, sexo y edad de 100 personas, debe imprimir el total de hombres y mujeres aptos para votar, el total de personas aptas para votar y el porcentaje de personas aptas para votar.
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
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
program PersonasAptasParaVotar;
uses crt;
var edad, hombres, i, mujeres, personas : integer;
var porcentaje, sexo : integer;
var nombre, apellido : string;
begin
hombres := 0;
mujeres := 0;
personas := 0;
porcentaje := 0;
for i:=1 to 100 do
begin
writeln ('PROCESO ', i);
write ('Ingresa el nombre: ');
readln (nombre);
write ('Ingresa el apellido: ');
readln (apellido);
write ('Ingresa el valor de edad: ');
readln (edad);
writeln ('Selecciona el valor de sexo.');
writeln (' 1.- Mujer');
writeln (' 2.- Hombre');
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 (sexo=2) and (edad>=18) then
begin
hombres := hombres+1;
end;
if (sexo=1) and (edad>=18) then
begin
mujeres := mujeres+1;
end;
if edad>=18 then
begin
personas := personas+1;
end;
writeln ('Nombre: ', nombre);
writeln ('Apellido: ', apellido);
writeln;
end;
porcentaje := personas;
writeln ('Valor de hombres: ', hombres);
writeln ('Valor de mujeres: ', mujeres);
writeln ('Valor de personas: ', personas);
writeln ('Valor de porcentaje: ', porcentaje);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var edad, hombres, i, mujeres, personas : integer;
var porcentaje, sexo : integer;
var nombre, apellido : string;
begin
hombres := 0;
mujeres := 0;
personas := 0;
porcentaje := 0;
for i:=1 to 100 do
begin
writeln ('PROCESO ', i);
write ('Ingresa el nombre: ');
readln (nombre);
write ('Ingresa el apellido: ');
readln (apellido);
write ('Ingresa el valor de edad: ');
readln (edad);
writeln ('Selecciona el valor de sexo.');
writeln (' 1.- Mujer');
writeln (' 2.- Hombre');
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 (sexo=2) and (edad>=18) then
begin
hombres := hombres+1;
end;
if (sexo=1) and (edad>=18) then
begin
mujeres := mujeres+1;
end;
if edad>=18 then
begin
personas := personas+1;
end;
writeln ('Nombre: ', nombre);
writeln ('Apellido: ', apellido);
writeln;
end;
porcentaje := personas;
writeln ('Valor de hombres: ', hombres);
writeln ('Valor de mujeres: ', mujeres);
writeln ('Valor de personas: ', personas);
writeln ('Valor de porcentaje: ', porcentaje);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.