Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program G03EJ16;
- var
- km,lit:real;
- pat:string[7];
- salida:text;
- letrasP,numerosP:integer;
- begin
- assign(salida,'kilometros.txt');rewrite(salida);
- repeat
- write('Ingrese los kilometros recorrido(0 para finalizar): ');readln(km);
- while km<0 do //Validacion para los kilometros recorridos//
- begin
- write('Ingrese un valor valido: ');readln(km);
- end;
- if km<>0 then
- begin
- write('Ingrese la patente: ');readln(pat);pat:=upcase(pat);
- //validacion de Patente//
- letrasP:=ord(pat[1])+ord(pat[2])+ord(pat[6])+ord(pat[7]);
- numerosP:=ord(pat[3])+ord(pat[4])+ord(pat[5]);
- while (letrasP<ord('A')*4) or (letrasP>ord('Z')*4) or (numerosP<ord('0')*3) or (numerosP>ord('9')*3) do
- begin
- writeln('Ingrese una patente valida: ');readln(pat);pat:=upcase(pat);
- letrasP:=ord(pat[1])+ord(pat[2])+ord(pat[6])+ord(pat[7]);
- numerosP:=ord(pat[3])+ord(pat[4])+ord(pat[5]);
- end;
- //Cree las variables para acortar la longitud de la funcion while//
- //Esta forma fue la forma mas optima que se me ocurre//
- write('Ingrese los litros consumidos: ');readln(lit);
- while lit<0 do //Validacion para los litros//
- begin
- write('Ingrese un valor valido: ');readln(lit);
- end;
- write(salida,pat,' ');
- writeln(salida,lit/km:0:2,'L/Km');
- end;
- until km=0;
- close(salida);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement