-
unit Unit1;
-
-
interface
-
-
uses
-
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
-
Dialogs, StdCtrls, ExtCtrls, Grids, math;
-
-
type
-
TForm1 = class(TForm)
-
deuda: TEdit;
-
interes: TEdit;
-
tiempo: TEdit;
-
salir: TButton;
-
limpiar: TButton;
-
amortizacion: TButton;
-
Label1: TLabel;
-
Label2: TLabel;
-
Label4: TLabel;
-
Label3: TLabel;
-
it: TLabel;
-
rg1: TRadioGroup;
-
rg2: TRadioGroup;
-
m: TStringGrid;
-
procedure FormActivate(Sender: TObject);
-
procedure salirClick(Sender: TObject);
-
procedure limpiarClick(Sender: TObject);
-
procedure deudaChange(Sender: TObject);
-
procedure interesChange(Sender: TObject);
-
procedure tiempoChange(Sender: TObject);
-
procedure rg1Click(Sender: TObject);
-
procedure rg2Click(Sender: TObject);
-
procedure amortizacionClick(Sender: TObject);
-
private
-
{ Private declarations }
-
public
-
{ Public declarations }
-
end;
-
-
var
-
Form1: TForm1;
-
fil,col,tf:integer;
-
pc,mes,si,i,sf,pm,deu,int,ti,im:real;
-
-
implementation
-
-
{$R *.dfm}
-
-
procedure TForm1.FormActivate(Sender: TObject);
-
begin
-
{Introducimos nombre de las columnas}
-
m.Cells[0,0]:='Mes';
-
m.Cells[1,0]:='Saldo Inicial';
-
m.Cells[2,0]:='Pago Capital';
-
m.Cells[3,0]:='Intereses';
-
m.Cells[4,0]:='Saldo Final';
-
m.Cells[5,0]:='Pago del Mes';
-
-
{Limpiamos las demas celdas}
-
for fil:=1 to m.rowcount -1 do
-
begin
-
for col:=0 to 5 do
-
m.cells[col,fil]:='';
-
end;
-
-
{Inicializamos matriz}
-
m.RowCount:=2
-
end;
-
-
procedure TForm1.salirClick(Sender: TObject);
-
begin
-
form1.Close;
-
end;
-
-
procedure TForm1.limpiarClick(Sender: TObject);
-
begin
-
{Limpiamos todo}
-
deuda.text:='';
-
interes.Text:='';
-
tiempo.Text:='';
-
amortizacion.Enabled:=false;
-
limpiar.Enabled:=false;
-
rg1.ItemIndex:=-1;
-
rg2.ItemIndex:=-1;
-
it.Caption:='';
-
deuda.SetFocus;
-
-
{Limpiamos variables}
-
fil:=0;
-
col:=0;
-
tf:=0;
-
pc:=0;
-
mes:=0;
-
si:=0;
-
i:=0;
-
sf:=0;
-
pm:=0;
-
deu:=0;
-
int:=0;
-
ti:=0;
-
im:=0;
-
-
{Limpiamos las demas celdas}
-
for fil:=1 to m.rowcount -1 do
-
begin
-
for col:=0 to 5 do
-
m.cells[col,fil]:='';
-
end;
-
-
{Inicializamos matriz}
-
m.RowCount:=2
-
end;
-
-
procedure TForm1.deudaChange(Sender: TObject);
-
begin
-
{condicion pora limpiar}
-
if (deuda.text<>'') or (interes.text<>'') or (tiempo.text<>'')
-
or (rg1.itemindex>-1) or (rg2.itemindex>-1) then
-
limpiar.Enabled:=true
-
else
-
limpiar.Enabled:=false;
-
-
{condicion para amortizar}
-
if (deuda.text<>'') and (interes.text<>'') and (tiempo.text<>'')
-
and (rg1.itemindex>-1) and (rg2.itemindex>-1) then
-
amortizacion.Enabled:=true
-
else
-
amortizacion.Enabled:=false;
-
end;
-
-
procedure TForm1.interesChange(Sender: TObject);
-
begin
-
{condicion pora limpiar}
-
if (deuda.text<>'') or (interes.text<>'') or (tiempo.text<>'')
-
or (rg1.itemindex>-1) or (rg2.itemindex>-1) then
-
limpiar.Enabled:=true
-
else
-
limpiar.Enabled:=false;
-
-
{condicion para amortizar}
-
if (deuda.text<>'') and (interes.text<>'') and (tiempo.text<>'')
-
and (rg1.itemindex>-1) and (rg2.itemindex>-1) then
-
amortizacion.Enabled:=true
-
else
-
amortizacion.Enabled:=false;
-
end;
-
-
procedure TForm1.tiempoChange(Sender: TObject);
-
begin
-
{condicion pora limpiar}
-
if (deuda.text<>'') or (interes.text<>'') or (tiempo.text<>'')
-
or (rg1.itemindex>-1) or (rg2.itemindex>-1) then
-
limpiar.Enabled:=true
-
else
-
limpiar.Enabled:=false;
-
-
{condicion para amortizar}
-
if (deuda.text<>'') and (interes.text<>'') and (tiempo.text<>'')
-
and (rg1.itemindex>-1) and (rg2.itemindex>-1) then
-
amortizacion.Enabled:=true
-
else
-
amortizacion.Enabled:=false;
-
end;
-
-
procedure TForm1.rg1Click(Sender: TObject);
-
begin
-
{condicion pora limpiar}
-
if (deuda.text<>'') or (interes.text<>'') or (tiempo.text<>'')
-
or (rg1.itemindex>-1) or (rg2.itemindex>-1) then
-
limpiar.Enabled:=true
-
else
-
limpiar.Enabled:=false;
-
-
{condicion para amortizar}
-
if (deuda.text<>'') and (interes.text<>'') and (tiempo.text<>'')
-
and (rg1.itemindex>-1) and (rg2.itemindex>-1) then
-
amortizacion.Enabled:=true
-
else
-
amortizacion.Enabled:=false;
-
end;
-
-
procedure TForm1.rg2Click(Sender: TObject);
-
begin
-
{condicion pora limpiar}
-
if (deuda.text<>'') or (interes.text<>'') or (tiempo.text<>'')
-
or (rg1.itemindex>-1) or (rg2.itemindex>-1) then
-
limpiar.Enabled:=true
-
else
-
limpiar.Enabled:=false;
-
-
{condicion para amortizar}
-
if (deuda.text<>'') and (interes.text<>'') and (tiempo.text<>'')
-
and (rg1.itemindex>-1) and (rg2.itemindex>-1) then
-
amortizacion.Enabled:=true
-
else
-
amortizacion.Enabled:=false;
-
end;
-
-
procedure TForm1.amortizacionClick(Sender: TObject);
-
begin
-
{inicializamos todo}
-
deu:=strtofloat(deuda.Text);
-
int:=strtofloat(interes.text);
-
ti:=strtofloat(tiempo.text);
-
-
{calculamos interes mensual}
-
if rg1.itemindex=0 then
-
im:=int/100
-
else
-
im:=(int/100)/12;
-
-
{primer columna}
-
if rg2.itemindex=0 then
-
mes:=ti
-
else
-
mes:=ti*12;
-
-
{Colocamos total de filas}
-
if rg2.itemindex=0 then
-
tf:=strtoint(tiempo.text)
-
else
-
tf:=strtoint(tiempo.text)*12;
-
-
m.RowCount:=tf +1;
-
for fil:=1 to tf do
-
m.cells[0,fil]:=floattostr(roundto(fil, -2));
-
-
{tercera columna}
-
pc:=deu/mes;
-
for fil:=1 to tf do
-
m.cells[2,fil]:=floattostr(roundto(pc, -2));
-
-
{segunda columna}
-
si:=deu+pc;
-
for fil:=1 to tf do
-
begin
-
si:=si-pc;
-
m.Cells[1,fil]:=floattostr(roundto(si, -2));
-
end;
-
-
{quinta columna}
-
sf:=deu;
-
for fil:=1 to tf do
-
begin
-
sf:=sf-pc;
-
m.Cells[4,fil]:=floattostr(roundto(sf, -2));
-
end;
-
-
{cuarta columna}
-
si:=deu+pc;
-
for fil:=1 to tf do
-
begin
-
si:=si-pc;
-
i:=si*im;
-
m.Cells[3,fil]:=floattostr(roundto(i, -2));
-
end;
-
-
{sexta columna}
-
pc:=deu/mes;
-
si:=deu+pc;
-
for fil:=1 to tf do
-
begin
-
si:=si-pc;
-
i:=si*im;
-
pm:=pc+i;
-
m.Cells[5,fil]:=floattostr(roundto(pm, -2));
-
end;
-
-
{interes total}
-
ti:=0;
-
for fil:=1 to tf do
-
ti:=ti+strtofloat(m.Cells[3,fil]);
-
it.Caption:=floattostr(roundto(ti,-2));
-
-
end;
-
-
end.
Dejar comentario