Pascal/Turbo Pascal - programa en turbo pascal

 
Vista:
sin imagen de perfil
Val: 14
Ha disminuido su posición en 2 puestos en Pascal/Turbo Pascal (en relación al último mes)
Gráfica de Pascal/Turbo Pascal

programa en turbo pascal

Publicado por miguel (7 intervenciones) el 28/02/2020 05:02:45
Buenas amigos me gustaria que me pudiesen ayudar con este programa en pascal que debo crear y me esta dando bastantes quebraderos de cabeza

Se me pide crear un programa que permita ingresar el nombre y el salario de los trabajadores de una empresa. asi como tambien poder consultarlos.

ya este paso esta hecho como mostrare en el archivo que adjuntrare creado en notepad++

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
program ACME;
 
type
    tipoPersona = record
        nombre: string;
        salario: integer;
 
 
    end;
 
const
    capacidad = 1000;
 
var
    tra: array[1..capacidad] of tipoPersona;
    cantidad: integer;
    opcion: integer;
    i: integer;
    textoBuscar: string;
    encontrado: boolean;
	sal_anu, sal_anual, sal_men, sal_mensual: integer;
	utili, utilidades, vaca, vacaciones: integer;
	bono: real;
 
{Cuerpo del programa principal}
begin
    cantidad := 0;
    repeat
        WriteLn('***BIENVENIDO A ACME***');
        WriteLn;
        WriteLn('1- Agregar Trabajador');
        WriteLn('2- Todos los trabajadores');
        WriteLn('3- Buscar a un trabajador');
        WriteLn('0- Salir');
        Write('Escoja una opcionn: ');
        ReadLn(opcion);
        WriteLn;
 
        case opcion of
            1: { Agregar trabajador }
                if (cantidad < capacidad) then
                begin
                    inc(cantidad);
                    WriteLn('Introduciendo al trabajador ', cantidad);
 
                    Write('Introduzca el nombre: ');
                    ReadLn(tra[cantidad].nombre);
 
                    Write('Introduzca Salario: ');
                    ReadLn(tra[cantidad].salario);
 
                     WriteLn;
                 end
                 else
                        WriteLn('Base de datos llena');
 
            2: { Todos los trabajadores }
                begin
                if cantidad = 0 then
                    WriteLn('No hay datos')
                else
                    for i := 1 to cantidad do
                        WriteLn(i, ' ', tra[i].nombre, tra[i] salario);
                WriteLn;
                end;
 
            3: { Buscar a un trabajador }
                begin
                Write('Escriba el nombre del trabajador ');
                ReadLn( textoBuscar );
                encontrado := false;
                for i := 1 to cantidad do
                    if pos (textoBuscar, tra[i].nombre) > 0 then
                    begin
                        encontrado := true;
                        WriteLn( i,' - Nombre: ', tra[i].nombre,
                          ', Salario: ', tra[i].salario;
                    end;
                if not encontrado then
                    WriteLn('No se ha encontrado.');
                WriteLn;
                end;
 
            0: { salir			}
                begin
                WriteLn;
                WriteLn('Saliendo...');
                WriteLn;
                end;
 
             else
                begin
                WriteLn;
                WriteLn('Opción incorrecta!');
                WriteLn;
                end;
        end;  { Fin de "case" }
 
    until opcion = 0;
end.


mi quebradero de cabeza es cuando se me pide realizar ciertos calculo en base al salario de los trabajadores, como por ejemplo utilidades, vacaciones, bonos, etc.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
begin
    for i:=0 to cantidad do
        if tra[i].salario > 15 then
            tra[i].bono:=tra[i].salario*0.1;
            utilidades:=tra[i].salario*2;
            vacaciones:=tra[i].salario;
            tra[i].sal_mensual:=tra[i].salario+tra[i]bono;
            tra[i].sal_anual:=tra[i].sal_mensual*12+vacaciones+utilidades;
        else
            cesta:=20;
            vaca:=tra[i].salario;
            utili:=tra[i].salario*4;
            tra[i].sal_men:=tra[i].salario+cesta;
            tra[i].sal_anu:=tra[i].sal_men*12+vaca;
end;

me gustaria que los revisaran para saber si estan correctos y como introducirlos en el codigo

esperando su pronta respuesta

muchas gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 14
Ha disminuido su posición en 2 puestos en Pascal/Turbo Pascal (en relación al último mes)
Gráfica de Pascal/Turbo Pascal

programa en turbo pascal

Publicado por miguel (7 intervenciones) el 29/02/2020 06:24:54
Buenas chicos he logrado hacer varias modificaciones al codigo de pascal

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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
program ACME;
 
type
    tipoPersona = record
        nombre: string;
        salario: real;
		sal_anu: integer;
		sal_anual: integer;
		sal_men: integer;
		sal_mensual: integer;
		utili, utilidades, vaca, vacaciones: integer;
		bono: real;
 
    end;
 
const
    capacidad = 1000;
 
var
    tra: array[1..capacidad] of tipoPersona;
    cantidad: integer;
    opcion: integer;
    i: integer;
    textoBuscar: string;
    encontrado: boolean;
	bono: real;
	cesta: integer;
 
 
 
{Cuerpo del programa principal}
begin
    cantidad := 0;
    repeat
        WriteLn('***BIENVENIDO A ACME***');
        WriteLn;
        WriteLn('1- Agregar Trabajador');
        WriteLn('2- Todos los trabajadores');
        WriteLn('3- Buscar a un trabajador');
        WriteLn('4- Reporte 1');
        WriteLn('5- Reporte 2');
        WriteLn('0- Salir');
        Write('Escoja una opcion: ');
        ReadLn(opcion);
        WriteLn;
 
        case opcion of
            1: { Agregar trabajador }
                if (cantidad < capacidad) then
                begin
                    inc(cantidad);
                    WriteLn('Introduciendo al trabajador ', cantidad);
 
                    Write('Introduzca el nombre: ');
                    ReadLn(tra[cantidad].nombre);
 
                    Write('Introduzca Salario: ');
                    ReadLn(tra[cantidad].salario);
 
					for i:=1 to cantidad do
					begin
						if tra[i].salario > 1500 then
							tra[i].bono:=tra[i].salario*0.1;
							tra[i].utilidades:=tra[i].salario*2;
							tra[i].vacaciones:=tra[i].salario;
							tra[i].sal_mensual:=tra[i].salario+tra[i].bono;
							tra[i].sal_anual:=tra[i].sal_mensual*12+tra.[i].vacaciones+tra[i].utilidades;
						end;
						if tra[i].salario <= 1500 then
						begin
							cesta:=20;
							tra[i].vaca:=tra[i].salario;
							tra[i].utili:=tra[i].salario*4;
							tra[i].sal_men:=tra[i].salario+cesta;
							tra[i].sal_anu:=tra[i].sal_men*12+tra.[i]vaca;
						end;
					end;
 
 
            2: { Todos los trabajadores }
                begin
                if cantidad = 0 then
                    WriteLn('No hay datos')
                else
                    for i := 1 to cantidad do
                        WriteLn(i, ' ', tra[i].nombre, tra[i].salario);
                WriteLn;
                end;
 
 
            3: { Buscar a un trabajador }
                begin
                Write('Escriba el nombre del trabajador ');
                ReadLn( textoBuscar );
                encontrado := false;
                for i := 1 to cantidad do
                    if pos (textoBuscar, tra[i].nombre) > 0 then
                    begin
                        encontrado := true;
                        WriteLn( i,' - Nombre: ', tra[i].nombre,
                          ', Salario: ', tra[i].salario);
                    end;
                if not encontrado then
                    WriteLn('No se ha encontrado.');
                WriteLn;
                end;
 
            4: { Reporte 1 }
				for i := 1 to cantidad do
                begin
                if tra[i].salario > 15 then
                begin
					writeln('Nombre del trabajador: ', tra[i].nombre);
                    WriteLn('Salario: ', tra[i].salario);
                    WriteLn('Bono: ', tra[i].bono);
                    WriteLn('Total: ', tra[i].sal_mensual);
                end;
                end;
 
            5: { Reporte 2 }
				for i := 1 to cantidad do
                begin
                if tra[i].salario <= 15 then
                begin
					writeln('Nombre del trabajador: ', tra[i].nombre);
                    WriteLn('Salario: ', tra[i].salario);
                    WriteLn('Cestaticket: ', cesta);
                    WriteLn('Total: ', tra[i].sal_men);
                end;
                end;
 
           0: { salir			}
                begin
                ;
                WriteLn;
                WriteLn('Saliendo...');
                WriteLn;
                end;
 
             else
                begin
                WriteLn;
                WriteLn('Opción incorrecta!');
                WriteLn;
                end;
        end;  { Fin de "case" }
 
    until opcion = 0;
end.


pero aparecen varios errores que no logro decifrar

prueba1.pas(64,41) Error: Incompatible types: got "Real" expected "SmallInt"
prueba1.pas(65,30) Error: Incompatible types: got "Real" expected "SmallInt"
prueba1.pas(66,42) Error: Incompatible types: got "Real" expected "SmallInt"
prueba1.pas(67,52) Error: Illegal qualifier
prueba1.pas(67,52) Fatal: Syntax error, "identifier" expected but "[" found
Fatal: Compilation aborted

me gustaria que me indicaran a que se deben estos errores y como poder solucionarlos

esperando su pronta respuesta

muchas gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 287
Oro
Ha mantenido su posición en Pascal/Turbo Pascal (en relación al último mes)
Gráfica de Pascal/Turbo Pascal

programa en turbo pascal

Publicado por dario (87 intervenciones) el 29/02/2020 15:04:20
Hola, tu mismo codigo arreglado.
Pruebalo y me avisas.
Saludos.

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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
program ACME;
 
type
    tipoPersona = record
        nombre: string;
        salario: real;
		sal_anu: real;
		sal_anual: real;
		sal_men: real;
		sal_mensual: real;
		utili, utilidades, vaca, vacaciones: real;
		bono: real;
 
    end;
 
const
    capacidad = 1000;
 
var
    tra: array[1..capacidad] of tipoPersona;
    cantidad: integer;
    opcion: integer;
    i: integer;
    textoBuscar: string;
    encontrado: boolean;
	bono: real;
	cesta: integer;
 
 
 
{Cuerpo del programa principal}
begin
    cantidad := 0;
    repeat
        WriteLn('***BIENVENIDO A ACME***');
        WriteLn;
        WriteLn('1- Agregar Trabajador');
        WriteLn('2- Todos los trabajadores');
        WriteLn('3- Buscar a un trabajador');
        WriteLn('4- Reporte 1');
        WriteLn('5- Reporte 2');
        WriteLn('0- Salir');
        Write('Escoja una opcion: ');
        ReadLn(opcion);
        WriteLn;
 
        case opcion of
            1: { Agregar trabajador }
                if (cantidad < capacidad) then
                begin
                    inc(cantidad);
                    WriteLn('Introduciendo al trabajador ', cantidad);
 
                    Write('Introduzca el nombre: ');
                    ReadLn(tra[cantidad].nombre);
 
                    Write('Introduzca Salario: ');
                    ReadLn(tra[cantidad].salario);
 
					for i:=1 to cantidad do
					begin
						if tra[i].salario > 1500 then begin
							tra[i].bono:=tra[i].salario*0.1;
							tra[i].utilidades:=tra[i].salario*2;
							tra[i].vacaciones:=tra[i].salario;
							tra[i].sal_mensual:=tra[i].salario+tra[i].bono;
							tra[i].sal_anual:=tra[i].sal_mensual*12+tra[i].vacaciones+tra[i].utilidades;
						end;
						if tra[i].salario <= 1500 then
						begin
							cesta:=20;
							tra[i].vaca:=tra[i].salario;
							tra[i].utili:=tra[i].salario*4;
							tra[i].sal_men:=tra[i].salario+cesta;
							tra[i].sal_anu:=tra[i].sal_men*12+tra[i].vaca;
						end;
					end;
				end;
 
            2: begin {Todos los trabajadores}
					if cantidad = 0 then
						WriteLn('No hay datos')
					else
						for i := 1 to cantidad do
							WriteLn(i, ' ', tra[i].nombre, tra[i].salario:4:2);
					WriteLn;
				end;
 
            3:  {Buscar a un trabajador}
                begin
                Write('Escriba el nombre del trabajador ');
                ReadLn( textoBuscar );
                encontrado := false;
                for i := 1 to cantidad do
                    if pos (textoBuscar, tra[i].nombre) > 0 then
                    begin
                        encontrado := true;
                        WriteLn( i,' - Nombre: ', tra[i].nombre,
                          ', Salario: ', tra[i].salario:4:2);
                    end;
                if not encontrado then
                    WriteLn('No se ha encontrado.');
                WriteLn;
                end;
 
            4:  {Reporte 1 }
				for i := 1 to cantidad do
                begin
                if tra[i].salario > 15 then
                begin
					writeln('Nombre del trabajador: ', tra[i].nombre);
                    WriteLn('Salario: ', tra[i].salario:4:2);
                    WriteLn('Bono: ', tra[i].bono:4:2);
                    WriteLn('Total: ', tra[i].sal_mensual:4:2);
                end;
                end;
 
            5: { Reporte 2}
				for i := 1 to cantidad do
                begin
                if tra[i].salario <= 15 then
                begin
					writeln('Nombre del trabajador: ', tra[i].nombre);
                    WriteLn('Salario: ', tra[i].salario:4:2);
                    WriteLn('Cestaticket: ', cesta);
                    WriteLn('Total: ', tra[i].sal_men:4:2);
                end;
                end;
 
           0: { salir}
                begin
                ;
                WriteLn;
                WriteLn('Saliendo...');
                WriteLn;
                end;
 
             else
                begin
                WriteLn;
                WriteLn('Opción incorrecta!');
                WriteLn;
                end;
        end;  { Fin de "case" }
 
    until opcion = 0;
end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
sin imagen de perfil
Val: 14
Ha disminuido su posición en 2 puestos en Pascal/Turbo Pascal (en relación al último mes)
Gráfica de Pascal/Turbo Pascal

programa en turbo pascal

Publicado por miguel (7 intervenciones) el 01/03/2020 05:22:29
Muchas gracias por tu pronta respuesta. Ha compilado correctamente muchisimas gracias.

pero tengo problema y es a la hora de insertar un codigo para eliminar a un trabajador de la lista

el codigo deberia poder borrar el nombre, el salario, los bonos y demas de dicho trabajador

he ingresado el siguiente codigo que deberia eliminar al trabajador

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
begin
 
  seBorro := false;
 
  for i := 1 to capacidad do
 
    ReadLn(tra[cantidad].nombre);
 
  if pos (textoBuscar, tra[cantidad].nombre) = tra[i].nombre then
 
   begin
 
    seBorro := true;
 
    fillchar(tra[i].salario, tra[i].sal_anu, tra[i].sal_anual, tra[i].sal_men, tra[i].sal_mensual, tra[i].utili, tra[i].utilidades, tra[i].vaca, tra[i].vacaciones, tra[i].bono;),0);
 
    end;
 
    if seBorro = true then
 
    writeln('El Trabajador indicado se ha borrado con exito')
 
end;

siendo esta la opcion 6 en el menu

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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
program ACME;
 
 
 
type
 
    tipoPersona = record
 
        nombre: string;
 
        salario: real;
 
		sal_anu: real;
 
		sal_anual: real;
 
		sal_men: real;
 
		sal_mensual: real;
 
		utili, utilidades, vaca, vacaciones: real;
 
		bono: real;
 
 
 
    end;
 
 
 
const
 
    capacidad = 1000;
 
 
 
var
 
    tra: array[1..capacidad] of tipoPersona;
 
    cantidad: integer;
 
    opcion: integer;
 
    i: integer;
 
    textoBuscar: string;
 
    encontrado: boolean;
 
	bono: real;
 
	cesta: integer;
 
	seBorro:boolean;
 
 
 
{Cuerpo del programa principal}
 
begin
 
    cantidad := 0;
 
    repeat
 
        WriteLn('***BIENVENIDO A ACME***');
 
        WriteLn;
 
        WriteLn('1- Agregar Trabajador');
 
        WriteLn('2- Todos los trabajadores');
 
        WriteLn('3- Buscar a un trabajador');
 
        WriteLn('4- Reporte 1');
 
        WriteLn('5- Reporte 2');
 
		WriteLn('6- Eliminar Trabajador');
 
        WriteLn('0- Salir');
 
        Write('Escoja una opcion: ');
 
        ReadLn(opcion);
 
        WriteLn;
 
 
 
        case opcion of
 
            1: { Agregar trabajador }
 
                if (cantidad < capacidad) then
 
                begin
 
                    inc(cantidad);
 
                    WriteLn('Introduciendo al trabajador ', cantidad);
 
 
 
                    Write('Introduzca el nombre: ');
 
                    ReadLn(tra[cantidad].nombre);
 
 
 
                    Write('Introduzca Salario: ');
 
                    ReadLn(tra[cantidad].salario);
 
 
 
					for i:=1 to cantidad do
 
					begin
 
						if tra[i].salario > 1500 then begin
 
							tra[i].bono:=tra[i].salario*0.1;
 
							tra[i].utilidades:=tra[i].salario*2;
 
							tra[i].vacaciones:=tra[i].salario;
 
							tra[i].sal_mensual:=tra[i].salario+tra[i].bono;
 
							tra[i].sal_anual:=tra[i].sal_mensual*12+tra[i].vacaciones+tra[i].utilidades;
 
						end;
 
						if tra[i].salario <= 1500 then
 
						begin
 
							cesta:=20;
 
							tra[i].vaca:=tra[i].salario;
 
							tra[i].utili:=tra[i].salario*4;
 
							tra[i].sal_men:=tra[i].salario+cesta;
 
							tra[i].sal_anu:=tra[i].sal_men*12+tra[i].vaca;
 
						end;
 
					end;
 
				end;
 
 
 
            2: begin {Todos los trabajadores}
 
					if cantidad = 0 then
 
						WriteLn('No hay datos')
 
					else
 
						for i := 1 to cantidad do
 
							WriteLn(i, ' ', tra[i].nombre, tra[i].salario:4:2);
 
					WriteLn;
 
				end;
 
 
 
            3:  {Buscar a un trabajador}
 
                begin
 
                Write('Escriba el nombre del trabajador ');
 
                ReadLn( textoBuscar );
 
                encontrado := false;
 
                for i := 1 to cantidad do
 
                    if pos (textoBuscar, tra[i].nombre) > 0 then
 
                    begin
 
                        encontrado := true;
 
                        WriteLn( i,' - Nombre: ', tra[i].nombre,
 
                          ', Salario: ', tra[i].salario:4:2);
 
                    end;
 
                if not encontrado then
 
                    WriteLn('No se ha encontrado.');
 
                WriteLn;
 
                end;
 
 
 
            4:  {Reporte 1 }
 
				for i := 1 to cantidad do
 
                begin
 
                if tra[i].salario > 1500 then
 
                begin
 
					writeln('Nombre del trabajador: ', tra[i].nombre);
 
                    WriteLn('Salario: ', tra[i].salario:4:2);
 
                    WriteLn('Bono: ', tra[i].bono:4:2);
 
                    WriteLn('Total: ', tra[i].sal_mensual:4:2);
 
                end;
 
                end;
 
 
 
            5: { Reporte 2}
 
				for i := 1 to cantidad do
 
                begin
 
                if tra[i].salario <= 1500 then
 
                begin
 
					writeln('Nombre del trabajador: ', tra[i].nombre);
 
                    WriteLn('Salario: ', tra[i].salario:4:2);
 
                    WriteLn('Cestaticket: ', cesta);
 
                    WriteLn('Total: ', tra[i].sal_men:4:2);
 
                end;
 
                end;
 
			6: 	{ Eliminar trabajador }
 
				begin
 
				  seBorro := false;
 
				  for i := 1 to capacidad do
 
					ReadLn(tra[cantidad].nombre);
 
				  if pos (textoBuscar, tra[cantidad].nombre) = tra[i].nombre then
 
				   begin
 
					seBorro := true;
 
					fillchar(tra[i].salario, tra[i].sal_anu, tra[i].sal_anual, tra[i].sal_men, tra[i].sal_mensual, tra[i].utili, tra[i].utilidades, tra[i].vaca, tra[i].vacaciones, tra[i].bono;),0);
 
					end;
 
					if seBorro = true then
 
					writeln('El Trabajador indicado se ha borrado con exito')
 
				  end;
 
 
           0: { salir}
 
                begin
 
                ;
 
                WriteLn;
 
                WriteLn('Saliendo...');
 
                WriteLn;
 
                end;
 
 
 
             else
 
                begin
 
                WriteLn;
 
                WriteLn('Opción incorrecta!');
 
                WriteLn;
 
                end;
 
        end;  { Fin de "case" }
 
 
 
    until opcion = 0;
 
end.

el problema surge que al compilar me arroja los errores:

prueba2.pas(267,10) Error: Incompatible types: got "LongInt" expected "ShortString"
prueba2.pas(273,177) Fatal: Syntax error, ")" expected but ";" found
Fatal: Compilation aborted
Ha fallado la compilación.

Creo que estoy haciendo algo mal ya que no creo que esa sea la forma para borrar la informacion

Esperando su pronta respuesta muchas gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 287
Oro
Ha mantenido su posición en Pascal/Turbo Pascal (en relación al último mes)
Gráfica de Pascal/Turbo Pascal

programa en turbo pascal

Publicado por dario (87 intervenciones) el 06/03/2020 09:10:34
Hola, pruebalo ahora.
Salu2.

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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
program ACME;
type
    tipoPersona = record
        nombre: string;
        salario: real;
		sal_anu: real;
		sal_anual: real;
		sal_men: real;
		sal_mensual: real;
		utili, utilidades, vaca, vacaciones: real;
		bono: real;
    end;
const
	capacidad = 1000;
var
	tra: array[1..capacidad] of tipoPersona;
    cantidad: integer;
    opcion: integer;
    i: integer;
    textoBuscar: string;
    encontrado: boolean;
	bono: real;
	cesta: integer;
	seBorro:boolean;
 
{Cuerpo del programa principal}
begin
	cantidad := 0;
    repeat
        WriteLn('***BIENVENIDO A ACME***');
        WriteLn;
        WriteLn('1- Agregar Trabajador');
        WriteLn('2- Todos los trabajadores');
        WriteLn('3- Buscar a un trabajador');
        WriteLn('4- Reporte 1');
        WriteLn('5- Reporte 2');
		WriteLn('6- Eliminar trabajador');
        WriteLn('0- Salir');
        Write('Escoja una opcion: ');
        ReadLn(opcion);
        WriteLn;
 
        case opcion of
			1: { Agregar trabajador }
				if (cantidad < capacidad) then
                begin
					inc(cantidad);
                    WriteLn('Introduciendo al trabajador ', cantidad);
                    Write('Introduzca el nombre: ');
                    ReadLn(tra[cantidad].nombre);
                    Write('Introduzca Salario: ');
                    ReadLn(tra[cantidad].salario);
					for i:=1 to cantidad do
					begin
						if tra[i].salario > 1500 then begin
							with tra[i] do begin
								bono:=tra[i].salario*0.1;
								utilidades:=tra[i].salario*2;
								vacaciones:=tra[i].salario;
								sal_mensual:=tra[i].salario+tra[i].bono;
								sal_anual:=tra[i].sal_mensual*12+tra[i].vacaciones+tra[i].utilidades;
							end;
						end;
						if tra[i].salario <= 1500 then
						begin
							cesta:=20;
							with tra[i] do begin
								vaca:=salario;
								utili:=salario*4;
								sal_men:=salario+cesta;
								sal_anu:=sal_men*12+tra[i].vaca;
							end;
						end;
					end;
				end;
            2: begin {Todos los trabajadores}
					if cantidad = 0 then
						WriteLn('No hay datos')
					else
						for i := 1 to cantidad do
							WriteLn(i, ' ', tra[i].nombre, tra[i].salario:4:2);
					WriteLn;
				end;
            3:  {Buscar a un trabajador}
                begin
					Write('Escriba el nombre del trabajador ');
					ReadLn( textoBuscar );
					encontrado := false;
					for i := 1 to cantidad do
						if pos (textoBuscar, tra[i].nombre) > 0 then
						begin
							encontrado := true;
							WriteLn( i,' - Nombre: ', tra[i].nombre,', Salario: ', tra[i].salario:4:2);
						end;
					if not encontrado then
						WriteLn('No se ha encontrado.');
					WriteLn;
                end;
            4:  {Reporte 1 }
				for i := 1 to cantidad do
                begin
					if tra[i].salario > 15 then
					begin
						writeln('Nombre del trabajador: ', tra[i].nombre);
						WriteLn('Salario: ', tra[i].salario:4:2);
						WriteLn('Bono: ', tra[i].bono:4:2);
						WriteLn('Total: ', tra[i].sal_mensual:4:2);
					end;
                end;
            5: { Reporte 2}
				for i := 1 to cantidad do
                begin
					if tra[i].salario <= 15 then
					begin
						writeln('Nombre del trabajador: ', tra[i].nombre);
						WriteLn('Salario: ', tra[i].salario:4:2);
						WriteLn('Cestaticket: ', cesta);
						WriteLn('Total: ', tra[i].sal_men:4:2);
					end;
                end;
            6: {Borra un trabajador}
				begin
					write('Nombre a buscar: ');
					readln(textoBuscar);
					seBorro := false;
					for i := 1 to capacidad do begin
						{ReadLn(tra[cantidad].nombre);}
						if (textoBuscar = tra[i].nombre) then
						begin
							seBorro := true;
							with tra[i] do begin
								nombre:='';
								salario:=0;
								sal_anu:=0.0;
								sal_anual:=0.0;
								sal_men:=0.0;
								sal_mensual:=0.0;
								utili:=0;
								utilidades:=0;
								vaca:=0;
								vacaciones:=0;
								bono:=0;
							end;
						end;
					end;
					if seBorro = true then
						writeln('El Trabajador indicado se ha borrado con exito')
				end;
           0: { salir}
				begin
					WriteLn;
					WriteLn('Saliendo...');
					WriteLn;
                end;
             else
                begin
					WriteLn;
					WriteLn('Opción incorrecta!');
					WriteLn;
                end;
        end;  { Fin de "case" }
    until opcion = 0;
end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
sin imagen de perfil
Val: 14
Ha disminuido su posición en 2 puestos en Pascal/Turbo Pascal (en relación al último mes)
Gráfica de Pascal/Turbo Pascal

programa en turbo pascal

Publicado por miguel (7 intervenciones) el 07/03/2020 03:36:31
Muchas gracias por tu ayuda a logrado compilar exitosamente el programa

sigo agregandole mas cosas a este

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
7: {Promedio Nomina Mayor}
 
				begin
 
					for i := 1 to capacidad do begin
 
						if tra[i].salario > 1500 then
 
						begin
 
						acum := acum+ tra[i].sal_anual:4:2;
 
						end;
 
						writeln('Promedio Nomina Mayor es: ' acum/tra[cantidad].nombre:4:2);
					end;
				end;

esto me permite crear un promedio entre los trabajadores que ganan mas de 1500

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
8: {Promedio Nomina Menor}
 
				begin
 
					for i := 1 to capacidad do begin
 
						if tra[i].salario <= 15 then
 
						begin
 
						acum := acum+ tra[i].sal_anu:4:2;
 
						end;
 
						writeln('Promedio Nomina Menor es: ' acum/tra[cantidad].nombre:4:2)

este me permite crear un promedio entre los trabajadores que ganan menos o igual a 1500

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
9: {Promedio general}
 
				begin
 
					for i := 1 to capacidad do begin
 
						begin
 
						sum := acum2+ acum;
 
						end;
 
						writeln('Promedio general es: ' sum/tra[cantidad].nombre:4:2);
 
				end;

y este me permite crear un promedio entre todos los trabajadores.

el problema es que no me deja compilar ya que me aparecen estos errores:

Compiling prueba7.pas
prueba7.pas(309,5) Error: Label used but not defined "7"
prueba7.pas(309,5) Fatal: Syntax error, ";" expected but "BEGIN" found
Fatal: Compilation aborted

me gustaria saber porque sigue apareciendo este error y como solucionarlo ya que no me deja compilar el resto del codigo.

ademas me gustaria saber si estoy haciendo los calculos adecuadamente

y tambien como ordenarlos para que aparezca que trabajador de la nomina menor gana mas que uno de la nomina mayor

aqui escribo el codigo completo

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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
program ACME;
 
type
 
    tipoPersona = record
 
        nombre: string;
 
        salario: real;
 
		sal_anu: real;
 
		sal_anual: real;
 
		sal_men: real;
 
		sal_mensual: real;
 
		utili, utilidades, vaca, vacaciones: real;
 
		bono: real;
 
		cedula :integer;
 
    end;
 
const
 
	capacidad = 1000;
 
var
 
	tra: array[1..capacidad] of tipoPersona;
 
    cantidad: integer;
 
    opcion: integer;
 
    i: integer;
 
    textoBuscar: string;
 
    encontrado: boolean;
 
	bono: real;
 
	cesta: integer;
 
	seBorro:boolean;
 
	acum :real;
 
	acum2 :real;
 
	sum : real;
 
 
 
 
 
{Cuerpo del programa principal}
 
begin
 
	cantidad := 0;
 
    repeat
 
        WriteLn('***BIENVENIDO A ACME***');
 
        WriteLn;
 
        WriteLn('1- Agregar Trabajador');
 
        WriteLn('2- Todos los trabajadores');
 
        WriteLn('3- Buscar a un trabajador');
 
        WriteLn('4- Reporte 1');
 
        WriteLn('5- Reporte 2');
 
		WriteLn('6- Eliminar trabajador');
 
		WriteLn('7- Promedio Nomina Mayor');
 
		WriteLn('8- Promedio Nomina Menor');
 
		WriteLn('9- Promedio General');
 
        WriteLn('0- Salir');
 
        Write('Escoja una opcion: ');
 
        ReadLn(opcion);
 
        WriteLn;
 
 
 
        case opcion of
 
			1: { Agregar trabajador }
 
				if (cantidad < capacidad) then
 
                begin
 
					inc(cantidad);
 
                    WriteLn('Introduciendo al trabajador ', cantidad);
 
                    Write('Introduzca el nombre: ');
 
                    ReadLn(tra[cantidad].nombre);
 
                    Write('Introduzca Salario: ');
 
                    ReadLn(tra[cantidad].salario);
 
					for i:=1 to cantidad do
 
					begin
 
						if tra[i].salario > 1500 then begin
 
							with tra[i] do begin
 
								bono:=tra[i].salario*0.1;
 
								utilidades:=tra[i].salario*2;
 
								vacaciones:=tra[i].salario;
 
								sal_mensual:=tra[i].salario+tra[i].bono;
 
								sal_anual:=tra[i].sal_mensual*12+tra[i].vacaciones+tra[i].utilidades;
 
							end;
 
						end;
 
						if tra[i].salario <= 1500 then
 
						begin
 
							cesta:=20;
 
							with tra[i] do begin
 
								vaca:=salario;
 
								utili:=salario*4;
 
								sal_men:=salario+cesta;
 
								sal_anu:=sal_men*12+tra[i].vaca;
 
							end;
 
						end;
 
					end;
 
				end;
 
            2: begin {Todos los trabajadores}
 
					if cantidad = 0 then
 
						WriteLn('No hay datos')
 
					else
 
						for i := 1 to cantidad do
 
							WriteLn(i, ' ', tra[i].nombre, tra[i].salario:4:2);
 
					WriteLn;
 
				end;
 
            3:  {Buscar a un trabajador}
 
                begin
 
					Write('Escriba el nombre del trabajador ');
 
					ReadLn( textoBuscar );
 
					encontrado := false;
 
					for i := 1 to cantidad do
 
						if pos (textoBuscar, tra[i].nombre) > 0 then
 
						begin
 
							encontrado := true;
 
							WriteLn( i,' - Nombre: ', tra[i].nombre,', Salario: ', tra[i].salario:4:2);
 
						end;
 
					if not encontrado then
 
						WriteLn('No se ha encontrado.');
 
					WriteLn;
 
                end;
 
            4:  {Reporte 1 }
 
				for i := 1 to cantidad do
 
                begin
 
					if tra[i].salario > 1500 then
 
					begin
 
						writeln('Nombre del trabajador: ', tra[i].nombre);
 
						WriteLn('Salario: ', tra[i].salario:4:2);
 
						WriteLn('Bono: ', tra[i].bono:4:2);
 
						WriteLn('Total: ', tra[i].sal_mensual:4:2);
 
					end;
 
                end;
 
            5: { Reporte 2}
 
				for i := 1 to cantidad do
 
                begin
 
					if tra[i].salario <= 1500 then
 
					begin
 
						writeln('Nombre del trabajador: ', tra[i].nombre);
 
						WriteLn('Salario: ', tra[i].salario:4:2);
 
						WriteLn('Cestaticket: ', cesta);
 
						WriteLn('Total: ', tra[i].sal_men:4:2);
 
					end;
 
                end;
 
            6: {Borra un trabajador}
 
				begin
 
					write('Nombre a buscar: ');
 
					readln(textoBuscar);
 
					seBorro := false;
 
					for i := 1 to capacidad do begin
 
						{ReadLn(tra[cantidad].nombre);}
 
						if (textoBuscar = tra[i].nombre) then
 
						begin
 
							seBorro := true;
 
							with tra[i] do begin
 
								nombre:='';
 
								salario:=0;
 
								sal_anu:=0.0;
 
								sal_anual:=0.0;
 
								sal_men:=0.0;
 
								sal_mensual:=0.0;
 
								utili:=0;
 
								utilidades:=0;
 
								vaca:=0;
 
								vacaciones:=0;
 
								bono:=0;
 
							end;
 
						end;
 
					end;
 
            7: {Promedio Nomina Mayor}
 
				begin
 
					for i := 1 to capacidad do begin
 
						if tra[i].salario > 1500 then
 
						begin
 
						acum := acum+ tra[i].sal_anual:4:2;
 
						end;
 
						writeln('Promedio Nomina Mayor es: ' acum/tra[cantidad].nombre:4:2);
					end;
				end;
 
            8: {Promedio Nomina Menor}
 
				begin
 
					for i := 1 to capacidad do begin
 
						if tra[i].salario <= 1500 then
 
						begin
 
						acum := acum+ tra[i].sal_anu:4:2;
 
						end;
 
						writeln('Promedio Nomina Menor es: ' acum/tra[cantidad].nombre:4:2)
 
            9: {Promedio general}
 
				begin
 
					for i := 1 to capacidad do begin
 
						begin
 
						sum := acum2+ acum;
 
						end;
 
						writeln('Promedio general es: ' sum/tra[cantidad].nombre:4:2);
 
				end;
 
           0: { salir}
 
				begin
 
					WriteLn;
 
					WriteLn('Saliendo...');
 
					WriteLn;
 
                end;
 
             else
 
                begin
 
					WriteLn;
 
					WriteLn('Opción incorrecta!');
 
					WriteLn;
 
                end;
 
        end;  { Fin de "case" }
 
    until opcion = 0;
 
end.

Esperando su pronta respuesta

muchisimas gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 14
Ha disminuido su posición en 2 puestos en Pascal/Turbo Pascal (en relación al último mes)
Gráfica de Pascal/Turbo Pascal

programa en turbo pascal

Publicado por miguel (7 intervenciones) el 08/03/2020 23:22:35
he logrado resolver los errores de compilacion antes mencionados pero al compilar los codigos para el promedio de la nomina mayor y menor

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
7: {Promedio Nomina Mayor}
 
    begin
 
        for i := 1 to capacidad do begin
 
            if tra[i].salario > 1500 then
 
            begin
 
            acum:=0;
 
            acum:=acum+tra[i].sal_anual;
 
            writeln('Promedio Nomina Mayor es:');
 
            writeln('tra[i].acum/tra:4.2');
 
            end;
 
        end;
 
    end;
 
8: {Promedio Nomina Menor}
 
    begin
 
        for i := 1 to capacidad do begin
 
            if tra[i].salario <= 1500 then
 
            begin
 
            acum2:= acum+ tra[i].sal_anu;
 
            writeln('Promedio Nomina Menor es:');
 
            writeln('tra[i].acum2/tra:4:2');
 
            end;
 
        end;
 
    end;

y el promedio general

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
9: {Promedio general}
 
    begin
 
        for i := 1 to capacidad do begin
 
            begin
 
            sum:=0;
 
            sum:=acum2+ acum;
 
            writeln('Promedio general es:');
 
            writeln('tra[i].sum/tra:4:2');
 
            end;
 
        end;
 
    end;

me aparecen las siguientes notas:


Compiling prueba7.pas
prueba7.pas(45,2) Note: Local variable "bono" not used
prueba7.pas(49,2) Note: Local variable "seBorro" is assigned but never used
prueba7.pas(55,2) Note: Local variable "sum" is assigned but never used
Linking prueba7.exe
405 lines compiled, 0.5 sec, 44928 bytes code, 3332 bytes data
3 note(s) issued
La compilación ha terminado con éxito.

no entiendo porque aparecen ademas al ejecutar el programa cuando eligo las opciones de los promedios me aparece lo siguiente

pascal

me gustaria saber porque no me esta dando los promedios

esperando su pronta respuesta muchas gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 14
Ha disminuido su posición en 2 puestos en Pascal/Turbo Pascal (en relación al último mes)
Gráfica de Pascal/Turbo Pascal

programa en turbo pascal

Publicado por miguel (7 intervenciones) el 10/03/2020 04:15:09
ya he logrado resolver el problema de los promedios aunque me gustaria que los pudieses revisar.

estos son los enunciados para los cuales el programa es creado

0002_opt
0003_opt

tambien le he cambiado algunas cosas al codigo como agregarle la cedula de identidad al trabajador pero me surge una duda

uno de los puntos es que el programa deberia escribir que trabajador de la nomina menor gana mas que uno de la nomina mayor (salario anual).

he incluido el numero de cedula de identidad ya que la profesora me ha sugerido para resolver este problema usar el metodo de ordenamiento de la burbuja

he investigado algo por internet y los ejemplos que aprecen son para las listas y no para arrays como el del programa.

mi pregunta seria si seria igual o hay que hacer algo extra

muchisimas gracias por tu ayuda aqui dejo el codigo hasta ahora

P.D: la cedula es el numero de identificacion personal en mi pais y la cestaticket es un bono de alimentacion que se le da a cada trabajador.

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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
program ACME;
 
type
 
    tipoPersona = record
 
        nombre: string;
 
        salario: real;
 
		sal_anu: real;
 
		sal_anual: real;
 
		sal_men: real;
 
		sal_mensual: real;
 
		utili, utilidades, vaca, vacaciones: real;
 
		bono: real;
 
		cedula :string;
 
    end;
 
const
 
	capacidad = 1000;
 
var
 
	tra: array[1..capacidad] of tipoPersona;
 
    cantidad: integer;
 
    opcion: integer;
 
    i: integer;
 
    textoBuscar: string;
 
    encontrado: boolean;
 
	bono: real;
 
	cesta: integer;
 
	seBorro:boolean;
 
	acumMedia :real;
 
	contMedia: integer;
 
 
 
 
 
{Cuerpo del programa principal}
 
begin
 
	cantidad := 0;
 
    repeat
 
        WriteLn('***BIENVENIDO A ACME***');
 
        WriteLn;
 
        WriteLn('1- Agregar Trabajador');
 
        WriteLn('2- Todos los trabajadores');
 
        WriteLn('3- Buscar a un trabajador');
 
        WriteLn('4- Reporte 1');
 
        WriteLn('5- Reporte 2');
 
		WriteLn('6- Eliminar trabajador');
 
		WriteLn('7- Promedio Nomina Mayor');
 
		WriteLn('8- Promedio Nomina Menor');
 
		WriteLn('9- Promedio General');
 
        WriteLn('0- Salir');
 
        Write('Escoja una opcion: ');
 
        ReadLn(opcion);
 
        WriteLn;
 
 
 
        case opcion of
 
			1: { Agregar trabajador }
 
				if (cantidad < capacidad) then
 
                begin
 
					inc(cantidad);
 
                    WriteLn('Introduciendo al trabajador ', cantidad);
 
                    Write('Introduzca Cedula del trabajador: ');
 
                    ReadLn(tra[cantidad].cedula);
 
					Write('Introduzca el nombre del trabajador: ');
 
                    ReadLn(tra[cantidad].nombre);
 
                    Write('Introduzca Salario: ');
 
                    ReadLn(tra[cantidad].salario);
 
					for i:=1 to cantidad do
 
					begin
 
						if tra[i].salario > 1500 then begin
 
							with tra[i] do begin
 
								bono:=tra[i].salario*0.1;
 
								utilidades:=tra[i].salario*2;
 
								vacaciones:=tra[i].salario;
 
								sal_mensual:=tra[i].salario+tra[i].bono;
 
								sal_anual:=tra[i].sal_mensual*12+tra[i].vacaciones+tra[i].utilidades;
 
							end;
 
						end;
 
						if tra[i].salario <= 1500 then
 
						begin
 
							cesta:=20;
 
							with tra[i] do begin
 
								vaca:=salario;
 
								utili:=salario*4;
 
								sal_men:=salario+cesta;
 
								sal_anu:=sal_men*12+tra[i].vaca;
 
							end;
 
						end;
 
					end;
 
				end;
 
            2: begin {Todos los trabajadores}
 
					if cantidad = 0 then
 
						WriteLn('No hay datos')
 
					else
 
						for i := 1 to cantidad do
 
							WriteLn(i, ' ',tra[i].cedula, tra[i].nombre, tra[i].salario:4:2);
 
					WriteLn;
 
				end;
 
            3:  {Buscar a un trabajador}
 
                begin
 
					Write('Escriba cedula del trabajador ');
 
					ReadLn( textoBuscar );
 
					encontrado := false;
 
					for i := 1 to cantidad do
 
						if pos (textoBuscar, tra[i].cedula) > 0 then
 
						begin
 
							encontrado := true;
 
							WriteLn( i,' - Cedula: ', tra[i].cedula,',Nombre: ', tra[i].nombre,', Salario: ', tra[i].salario:4:2);
 
						end;
 
					if not encontrado then
 
						WriteLn('No se ha encontrado.');
 
					WriteLn;
 
                end;
 
            4:  {Reporte 1 }
 
				for i := 1 to cantidad do
 
                begin
 
					if tra[i].salario > 1500 then
 
					begin
 
						writeln('Nombre del trabajador: ', tra[i].nombre);
 
						WriteLn('Salario: ', tra[i].salario:4:2);
 
						WriteLn('Bono: ', tra[i].bono:4:2);
 
						WriteLn('Total: ', tra[i].sal_mensual:4:2);
 
					end;
 
                end;
 
            5: { Reporte 2}
 
				for i := 1 to cantidad do
 
                begin
 
					if tra[i].salario <= 1500 then
 
					begin
 
						writeln('Nombre del trabajador: ', tra[i].nombre);
 
						WriteLn('Salario: ', tra[i].salario:4:2);
 
						WriteLn('Cestaticket: ', cesta);
 
						WriteLn('Total: ', tra[i].sal_men:4:2);
 
					end;
 
                end;
 
            6: {Borra un trabajador}
 
				begin
 
					write('Nombre a buscar: ');
 
					readln(textoBuscar);
 
					seBorro := false;
 
					for i := 1 to cantidad do begin
 
						{ReadLn(tra[cantidad].nombre);}
 
						if (textoBuscar = tra[i].nombre) then
 
						begin
 
							seBorro := true;
							dec(cantidad);
 
							with tra[i] do begin
 
								nombre:='';
 
								salario:=0;
 
								sal_anu:=0.0;
 
								sal_anual:=0.0;
 
								sal_men:=0.0;
 
								sal_mensual:=0.0;
 
								utili:=0;
 
								utilidades:=0;
 
								vaca:=0;
 
								vacaciones:=0;
 
								bono:=0;
 
							end;
 
						end;
 
					end;
				end;
 
            7: {Promedio Nomina Mayor}
 
				begin
 
				acumMedia:= 0;
 
				contMedia:= 0;
 
					for i := 1 to cantidad do
 
						if tra[i].salario > 1500 then
 
						begin
 
						acumMedia := acumMedia + tra[i].salario;
 
						inc(contMedia);
 
						end;
 
					if (contMedia = 0) then
 
						writeln('No hay empleados con salario mayor de 1500')
 
					else
 
						writeln('Promedio Nomina Mayor es: ', acumMedia/contMedia:4:2);
				end;
 
            8: {Promedio Nomina Menor}
 
				begin
 
				acumMedia:= 0;
 
				contMedia:= 0;
 
					for i := 1 to cantidad do
 
						if tra[i].salario <= 1500 then
 
						begin
 
						acumMedia := acumMedia + tra[i].salario;
 
						inc(contMedia);
 
						end;
 
					if (contMedia = 0) then
 
						writeln('No hay empleados con salario menor o igual a 1500')
 
					else
 
						writeln('Promedio Nomina Menor es: ', acumMedia/contMedia:4:2);
				end;
 
            9: {Promedio general}
 
				begin
 
				if (cantidad = 0) then
 
					writeln('No hay trabajadores registrados')
 
				else
 
					begin
 
					acumMedia:= 0;
 
					contMedia:= 0;
 
						for i := 1 to cantidad do
 
						begin
 
							acumMedia := acumMedia + tra[i].salario;
 
							inc(contMedia);
 
						end;
 
						writeln('Promedio general es: ', acumMedia/contMedia:4:2);
 
					end;
				end;
 
           0: { salir}
 
				begin
 
					WriteLn;
 
					WriteLn('Saliendo...');
 
					WriteLn;
 
                end;
 
             else
 
                begin
 
					WriteLn;
 
					WriteLn('Opción incorrecta!');
 
					WriteLn;
 
                end;
 
        end;  { Fin de "case" }
 
    until opcion = 0;
 
end.

muchas gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar