-
Lenguaje
Pascal
-
Descripción
En una tienda se ha registrado N clientes durante el mes, llenaron una ficha de atención con los siguientes datos Edad y Sexo (1-Masculino, 2-Femenino) de cada cliente atendido.
Determinar la cantidad de hombres y mujeres ha ingresado a la tienda durante el mes, también determinar el porcentaje de hombres y mujeres atendidos.
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 RegistroDeClientes;
uses crt;
var hombres, i, mujeres, n, sexo : integer;
var porcentaje_hombres, porcentaje_mujeres : real;
var edad : string;
begin
hombres := 0;
mujeres := 0;
porcentaje_hombres := 0;
porcentaje_mujeres := 0;
write ('Ingresa el valor de n: ');
readln (n);
for i:=1 to n do
begin
writeln ('PROCESO ', i);
write ('Ingresa el edad: ');
readln (edad);
writeln ('Selecciona el valor de sexo.');
writeln (' 1.- Masculino');
writeln (' 2.- Femenino');
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=1 then
begin
hombres := hombres+1;
end
else
begin
mujeres := mujeres+1;
end;
writeln ('Edad: ', edad);
writeln;
end;
if n = 0 then
porcentaje_hombres := 0
else
porcentaje_hombres := 100.0*hombres/n;
if n = 0 then
porcentaje_mujeres := 0
else
porcentaje_mujeres := 100.0*mujeres/n;
writeln ('Valor de hombres: ', hombres);
writeln ('Valor de mujeres: ', mujeres);
writeln ('Valor de porcentaje hombres: ', porcentaje_hombres:0:6);
writeln ('Valor de porcentaje mujeres: ', porcentaje_mujeres:0:6);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var hombres, i, mujeres, n, sexo : integer;
var porcentaje_hombres, porcentaje_mujeres : real;
var edad : string;
begin
hombres := 0;
mujeres := 0;
porcentaje_hombres := 0;
porcentaje_mujeres := 0;
write ('Ingresa el valor de n: ');
readln (n);
for i:=1 to n do
begin
writeln ('PROCESO ', i);
write ('Ingresa el edad: ');
readln (edad);
writeln ('Selecciona el valor de sexo.');
writeln (' 1.- Masculino');
writeln (' 2.- Femenino');
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=1 then
begin
hombres := hombres+1;
end
else
begin
mujeres := mujeres+1;
end;
writeln ('Edad: ', edad);
writeln;
end;
if n = 0 then
porcentaje_hombres := 0
else
porcentaje_hombres := 100.0*hombres/n;
if n = 0 then
porcentaje_mujeres := 0
else
porcentaje_mujeres := 100.0*mujeres/n;
writeln ('Valor de hombres: ', hombres);
writeln ('Valor de mujeres: ', mujeres);
writeln ('Valor de porcentaje hombres: ', porcentaje_hombres:0:6);
writeln ('Valor de porcentaje mujeres: ', porcentaje_mujeres:0:6);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.