-
Lenguaje
Pascal
-
Descripción
Una empresa tiene N empleados, cada uno posee una ficha que contiene los siguientes datos:
- Nombre.
- Edad de la persona.
- Estado civil (S,C,V,D).
- Sexo (F/M).
- Sueldo.
- Número de hijos
Se pide desarrollar un programa para determinar:
a) El total de mujeres casadas que ganan más de 100,000 bolívares y tenga más de dos hijos.
b) La edad promedio de las mujeres.
c) El total de hombres solteros menores de 40 años que ganan menos de 200,000 bolívares.
d) El total de viudos con más tres hijos.
e) Promedio de hijos de todos los empleados.
f) Porcentaje de hombres y mujeres.
g) Promedio de sueldos.
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
program FichasDeNEmpleados;
uses crt;
var a, c, d, estado_civil, hombres : integer;
var i, mujeres, n, sexo : integer;
var b, e, edad, g, numero_de_hijos : real;
var porcentaje_de_hombres, porcentaje_de_mujeres, sueldo : real;
var nombre : string;
begin
a := 0;
c := 0;
d := 0;
hombres := 0;
mujeres := 0;
b := 0;
e := 0;
g := 0;
porcentaje_de_hombres := 0;
porcentaje_de_mujeres := 0;
write ('Ingresa el valor de n: ');
readln (n);
for i:=1 to n do
begin
writeln ('PROCESO ', i);
write ('Ingresa el nombre: ');
readln (nombre);
write ('Ingresa el valor de edad: ');
readln (edad);
write ('Ingresa el valor de numero de hijos: ');
readln (numero_de_hijos);
write ('Ingresa el valor de sueldo: ');
readln (sueldo);
writeln ('Selecciona el valor de estado civil.');
writeln (' 1.- Soltero');
writeln (' 2.- Casado');
writeln (' 3.- Viudo');
writeln (' 4.- D');
write (' : ');
repeat
readln (estado_civil);
if (estado_civil<1) or (estado_civil>4) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (estado_civil>=1) and (estado_civil<=4);
writeln ('Selecciona el valor de sexo.');
writeln (' 1.- Femenino');
writeln (' 2.- Masculino');
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) and (estado_civil=2) and (sueldo>100000) and (numero_de_hijos>2) then
begin
a := a+1;
end;
if sexo=1 then
begin
mujeres := mujeres+1;
b := b+edad;
end
else
begin
hombres := hombres+1;
end;
if (sexo=2) and (estado_civil=1) and (edad<40) and (sueldo<200000) then
begin
c := c+1;
end;
if (estado_civil=3) and (numero_de_hijos>3) then
begin
d := d+1;
end;
e := e+numero_de_hijos;
g := g+sueldo;
writeln ('Nombre: ', nombre);
writeln;
end;
if mujeres = 0 then
b := 0
else
b := b/mujeres;
if n = 0 then
e := 0
else
e := e/n;
if n = 0 then
g := 0
else
g := g/n;
if n = 0 then
porcentaje_de_hombres := 0
else
porcentaje_de_hombres := 100.0*hombres/n;
if n = 0 then
porcentaje_de_mujeres := 0
else
porcentaje_de_mujeres := 100.0*mujeres/n;
writeln ('Valor de a: ', a);
writeln ('Valor de c: ', c);
writeln ('Valor de d: ', d);
writeln ('Valor de hombres: ', hombres);
writeln ('Valor de mujeres: ', mujeres);
writeln ('Valor de b: ', b:0:6);
writeln ('Valor de e: ', e:0:6);
writeln ('Valor de g: ', g:0:6);
writeln ('Valor de porcentaje de hombres: ', porcentaje_de_hombres:0:6);
writeln ('Valor de porcentaje de mujeres: ', porcentaje_de_mujeres:0:6);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var a, c, d, estado_civil, hombres : integer;
var i, mujeres, n, sexo : integer;
var b, e, edad, g, numero_de_hijos : real;
var porcentaje_de_hombres, porcentaje_de_mujeres, sueldo : real;
var nombre : string;
begin
a := 0;
c := 0;
d := 0;
hombres := 0;
mujeres := 0;
b := 0;
e := 0;
g := 0;
porcentaje_de_hombres := 0;
porcentaje_de_mujeres := 0;
write ('Ingresa el valor de n: ');
readln (n);
for i:=1 to n do
begin
writeln ('PROCESO ', i);
write ('Ingresa el nombre: ');
readln (nombre);
write ('Ingresa el valor de edad: ');
readln (edad);
write ('Ingresa el valor de numero de hijos: ');
readln (numero_de_hijos);
write ('Ingresa el valor de sueldo: ');
readln (sueldo);
writeln ('Selecciona el valor de estado civil.');
writeln (' 1.- Soltero');
writeln (' 2.- Casado');
writeln (' 3.- Viudo');
writeln (' 4.- D');
write (' : ');
repeat
readln (estado_civil);
if (estado_civil<1) or (estado_civil>4) then
write ('Valor incorrecto. Ingr'#130'salo nuevamente.: ');
until (estado_civil>=1) and (estado_civil<=4);
writeln ('Selecciona el valor de sexo.');
writeln (' 1.- Femenino');
writeln (' 2.- Masculino');
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) and (estado_civil=2) and (sueldo>100000) and (numero_de_hijos>2) then
begin
a := a+1;
end;
if sexo=1 then
begin
mujeres := mujeres+1;
b := b+edad;
end
else
begin
hombres := hombres+1;
end;
if (sexo=2) and (estado_civil=1) and (edad<40) and (sueldo<200000) then
begin
c := c+1;
end;
if (estado_civil=3) and (numero_de_hijos>3) then
begin
d := d+1;
end;
e := e+numero_de_hijos;
g := g+sueldo;
writeln ('Nombre: ', nombre);
writeln;
end;
if mujeres = 0 then
b := 0
else
b := b/mujeres;
if n = 0 then
e := 0
else
e := e/n;
if n = 0 then
g := 0
else
g := g/n;
if n = 0 then
porcentaje_de_hombres := 0
else
porcentaje_de_hombres := 100.0*hombres/n;
if n = 0 then
porcentaje_de_mujeres := 0
else
porcentaje_de_mujeres := 100.0*mujeres/n;
writeln ('Valor de a: ', a);
writeln ('Valor de c: ', c);
writeln ('Valor de d: ', d);
writeln ('Valor de hombres: ', hombres);
writeln ('Valor de mujeres: ', mujeres);
writeln ('Valor de b: ', b:0:6);
writeln ('Valor de e: ', e:0:6);
writeln ('Valor de g: ', g:0:6);
writeln ('Valor de porcentaje de hombres: ', porcentaje_de_hombres:0:6);
writeln ('Valor de porcentaje de mujeres: ', porcentaje_de_mujeres:0:6);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.