Pascal/Turbo Pascal - Cálculos con trabajadores

 
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

Cálculos con trabajadores

Publicado por miguel (7 intervenciones) el 05/03/2020 02:37:19
Hola tengo un problema que no sé como resolver. se me pide crear un programa que me permita ingresar datos de un trabajador como nombre y apellidos y su salario. ademas se me calcular si el salario de estos trabajadores es de 1500 se me pide calcular un bono del 10%, un mes de vacaciones, dos meses de utilidades y el total anual de todos estos. pero si es menor o igual a 1500 entonces calcularle un mes de vacaciones, meses de utilidades y el salario mensual. aunado a estos poder separarlos por tipo de salario mas su bono ademas de poderlos buscar y eliminar.

he logrado hacer algo del codigo como un array sobredimensionado pero creo que no es la mejor forma de hacerlo. me gustaria que me pudiesen ayudar a crearlo.

muchas gracias


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
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.
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