Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project1;
- uses
- crt;
- type
- REmpleado=record
- nombre:String[50];
- sueldo:real;
- categoria:string;
- end;
- TVector=array[1..100] of REmpleado;
- var
- Fichero:text;
- opc:Integer;
- empleados:TVector;
- linea:string;
- procedure CargarFichero(var Fichero:text);
- var
- cadena,nombre,strsueldo,categoria:string;
- resp:string;
- begin
- rewrite(fichero);
- writeln(Fichero,('Nombre Sueldo Categoria'));
- resp:='s';
- while (resp='s') do
- begin
- clrscr;
- writeln('Ingrese Nombre');
- readln(nombre);
- writeln('Ingrese Sueldo');
- readln(strsueldo);
- writeln('Ingrese Categoria (A/B)');
- readln(categoria);
- cadena:=nombre+chr(9)+strsueldo+chr(9)+categoria;
- writeln(Fichero,cadena) ;
- writeln('Desea seguir ingresando? s/n');
- readln(resp);
- end;
- close(Fichero);
- end;
- procedure mostrarFichero(var Fichero:text) ;
- var
- nombre:String[50];
- categoria:string;
- sueldo:String;
- p:integer;
- begin
- clrscr;
- {$I-}
- reset(Fichero);
- {$I-}
- if (IOResult<>0)then
- begin
- writeln('No se pudo acceder al fichero');
- readkey;
- end
- else
- begin
- readln(Fichero,linea);
- writeln(linea);
- writeln('*---------------------*');
- while (not eof(Fichero)) do
- begin
- readln(Fichero,linea);
- //Nombre---------------------
- p:=pos(chr(9),linea);
- nombre:= copy(linea,1,p-1);
- delete(linea,1,p);
- //Sueldo---------------------
- p:=pos(chr(9),linea);
- sueldo:= copy(linea,1,p-1);
- delete(linea,1,p);
- //Categoria------------------
- categoria:=linea;
- Writeln(nombre,' ',sueldo,' ',categoria);
- end;
- close(Fichero);
- readkey;
- end;
- end;
- procedure SumarCatB(var Fichero:text) ;
- var
- categoria:string;
- sueldo:String;
- p,ct,a,x,codigo:integer;
- begin
- clrscr;
- {$I-}
- reset(Fichero);
- {$I-}
- if (IOResult<>0)then
- begin
- writeln('No se pudo acceder al fichero');
- readkey;
- end
- else
- begin
- readln(Fichero,linea);
- ct:=0;
- x:=0;
- while (not eof(Fichero)) do
- begin
- readln(Fichero,linea);
- p:=pos(chr(9),linea);
- delete(linea,1,p);
- p:=pos(chr(9),linea);
- sueldo:= copy(linea,1,p-1);
- delete(linea,1,p);
- //Categoria------------------
- categoria:=linea;
- if categoria='b'then
- begin
- Val(sueldo,x,codigo) ;
- ct:=ct+x ;
- end;
- end;
- Writeln('La suma de sueldos de categoria B es: ',ct);
- close(Fichero);
- readkey;
- end;
- end;
- Procedure menu(var opc:integer);
- begin
- clrscr;
- writeln('1.- Cargar Archivo');
- writeln('2.- Mostras Lista');
- writeln('3.- Sumatoria de Sueldos de Categoria B');
- writeln('0.- Salir');
- readln(opc) ;
- end;
- begin
- assign (Fichero,'C:\Fichero.txt');
- repeat
- menu(opc);
- case opc of
- 0:writeln('Fin');
- 1:CargarFichero(Fichero);
- 2:mostrarFichero(Fichero) ;
- 3:SumarCatB(Fichero) ;
- else
- writeln('Opcion invalida');
- end;
- until opc=0;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement