program cajero;
uses crt;
var //Globales
saldo,numgi,numdep,op,gi,dep:integer;
(*******************************************************)
procedure giro(var numdep,numgi,saldo:integer;gi:integer);
//realiza giro
begin
repeat
write('Ingrese valor a girar = $');
readln(gi);
until(gi>0);
numgi:=numgi+1;
numdep:=numdep;
saldo:=saldo-gi;
end;
(*******************************************************)
procedure deposito(var numdep,numgi,saldo:integer;dep:integer);
//realiza deposito
begin
repeat
write('Ingrese valor a depositar = $');
readln(dep);
until(gi>0);
numdep:=numdep+1;
numgi:=numgi;
saldo:=saldo+dep;
end;
(*******************************************************)
procedure imprime(x,numgi,numdep,saldo:integer);
//imprime operacion
var
b20,b10,b5,b1,m500,m100,m50,m10,m1:integer;
begin
b20:=x div 20000;
x:=x-(20000*b20);
b10:=x div 10000;
x:=x-(10000*b10);
b5:=x div 5000;
x:=x-(5000*b5);
b1:=x div 1000;
x:=x-(1000*b1);
m500:=x div 500;
x:=x-(500*m500);
m100:=x div 100;
x:=x-(100*m100);
m50:=x div 50;
x:=x-(50*m50);
m10:=x div 10;
x:=x-(10*m10);
m1:=x div 1;
x:=x-(1*m1);
writeln('| $20000 =',b20:3 ,' |');
writeln('| $10000 =',b10:3 ,' |');
writeln('| $5000 =',b5:3 ,' |');
writeln('| $1000 =',b1:3 ,' |');
writeln('| $500 =',m500:3,' |');
writeln('| $100 =',m100:3,' |');
writeln('| $50 =',m50:3 ,' |');
writeln('| $10 =',m10:3 ,' |');
writeln('| $1 =',m1:3 ,' |');
writeln('==============================================================================');
writeln('Saldo |Deposito |Giro |Num. de Giros |Num. de Depositos| ');
writeln('==============================================================================');
writeln(saldo:12,dep:12,gi:12,numgi:12,numdep:12);
end;
(*******************************************************)
procedure menu;
begin
writeln('=================');
writeln('Banco PrograBank ');
writeln('=================');
writeln;
writeln('1.- Deposito');
writeln('2.- Retiro o Giro');
writeln('3.- Saldo');
writeln('4.- Salir');
end;
(*******************************************************)
(*******************Principal***************************)
begin
saldo:=100000;
numgi:=0;
numdep:=0;
menu;
repeat
writeln('Ingrese una opcion');
read(op);
case (op) of
1:begin
deposito(numdep,numgi,saldo,dep);
imprime(dep,numgi,numdep,saldo);
end;
2:begin
giro(numdep,numgi,saldo,gi);
imprime(gi,numgi,numdep,saldo);
end;
3:begin
imprime(0,numgi,numdep,saldo);
end;
4:begin
readkey;
end
else
begin
writeln('Ingrese una opcion valida');
end;
until (op=4);
end.