Program Veiculo;Type Estacionamento = record marca:string;
matricula:string;
tipo: string[20]; tempo: integer; end; Var fich: file of Estacionamento; auto: Estacionamento; escolha1: integer; escolha:char; valor:real; Procedure criar; begin Assign(fich,'Automoveis.txt'); Rewrite(fich); Close(fich); end; Procedure ler; begin Reset(fich); seek(fich, filesize(fich)); Write('Introduza a marca do ve¡culo'); Readln(auto.marca); Write('Introduza a matr¡cula'); readln(auto.matricula); Write('Introduza o tempo de estacionamento'); Readln(auto.tempo); Writeln('Introduza o tipo de veiculo'); readln(auto.tipo); write(fich,auto); Close(fich); end; Procedure Apresentar; Var apre:string; maior, soma:integer; media:real;
begin reset(fich); while not eof(fich) do begin read(fich,auto); write('Marca:',auto.marca); write('Matricula:',auto.matricula); write('Tempo de estacionamento:',auto.tempo); write('Tipo de veiculo:',auto.tipo); end; write('Tempo m‚dio=',soma/filesize(fich)); maior:=0; while not eof (fich) do begin if (auto.tempo>maior) then begin maior:=auto.tempo; apre:=auto.matricula; end; end; write('A matricula',apre,' foi quem esteve mais tempo no parque'); close(fich); end; Procedure Limpar; begin Assign(fich,'Automoveis.txt'); Rewrite(fich); Close(fich); end; Procedure Alterar; var escolha:char; mat:string; begin write('Pretende alterar algum dado? (S/N)'); readln(escolha); if (escolha='s') then begin reset(fich); read(fich,auto); while not eof (fich) do begin write('Introduza a matr¡cula cujo vai ser alterada'); read(mat); if mat=auto.matricula then begin write('Pretende alterar a matricula? (S/N)'); readln(escolha); if (escolha='s') then begin write('Matricula:'); readln(auto.matricula); end; write('Alterar Marca? (s/N)'); readln(escolha); if (escolha='s') then begin write('Marca:'); readln(auto.marca); end; write('Alterar tempo de estacionamento? (S/N)'); readln(escolha); if (escolha='s') then begin write('Tempo de estacionamento:'); readln(auto.tempo); end; write('Alterar tipo? (S/N)'); readln(escolha); if (escolha='s') then begin write('Tipo de veiculo:'); readln(auto.tipo); end; end; end; end; write(fich,auto); close(fich); end; Procedure valor_pago; var mt, lg, ps:real; begin reset(fich); while not eof (fich) do begin read(fich,auto); write('Matricula:',auto.matricula); write('Tipo:',auto.tipo); write('Marca:',auto.marca); write('Tempo:',auto.tempo); If auto.tipo='moto' then valor:= 0.04*auto.tempo*1.2; If auto.tipo='pesado' then valor:= 0.08*auto.tempo*1.2; If auto.tipo='ligeiro' then valor:= 0.1*auto.tempo*1.2; Writeln(auto.matricula,' ',auto.tempo,' ',valor); end; end; Begin //Programa Principal repeat writeln('1 - Para criar'); writeln('2 - Para ler'); writeln('3 - Para apresentar'); writeln('4 - Para Alterar'); writeln('5 - Para o valor pago'); writeln('6 - Para limpar'); writeln('7 - Para sair'); readln(escolha); case escolha1 of 1:criar; 2:ler; 3:apresentar; 4:alterar; 5:valor_pago; 6:limpar; end; until (escolha1=7); End.