Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Interessi composti - GestoreForm.pas

GestoreForm.pas

Caricato da: Poggi Marco
Scarica il programma completo

  1. unit GestoreForm;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls, Spin, ExtCtrls, LeggiNumeri;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     SpinEditAnni: TSpinEdit;
  12.     Label1: TLabel;
  13.     LabeledEditRendimentoPercentuale: TLabeledEdit;
  14.     LabeledEditSommaIniziale: TLabeledEdit;
  15.     LabeledEditRendimentoMensile: TLabeledEdit;
  16.     MemoElencoAnnuale: TMemo;
  17.     Label2: TLabel;
  18.     LabelSommaFinale: TLabel;
  19.     ButtonCalcola: TButton;
  20.     ButtonCancella: TButton;
  21.     Label3: TLabel;
  22.     Label4: TLabel;
  23.     Label5: TLabel;
  24.     procedure FormCreate(Sender: TObject);
  25.     procedure ButtonCancellaClick(Sender: TObject);
  26.     procedure LabeledEditRendimentoPercentualeKeyPress(Sender: TObject;
  27.       var Key: Char);
  28.     procedure LabeledEditSommaInizialeKeyPress(Sender: TObject;
  29.       var Key: Char);
  30.     procedure LabeledEditRendimentoMensileKeyPress(Sender: TObject;
  31.       var Key: Char);
  32.     procedure ButtonCalcolaClick(Sender: TObject);
  33.     procedure LabeledEditSommaInizialeKeyDown(Sender: TObject;
  34.       var Key: Word; Shift: TShiftState);
  35.     procedure LabeledEditRendimentoPercentualeKeyDown(Sender: TObject;
  36.       var Key: Word; Shift: TShiftState);
  37.     procedure LabeledEditRendimentoMensileKeyDown(Sender: TObject;
  38.       var Key: Word; Shift: TShiftState);
  39.   private
  40.     { Déclarations privées }
  41.     procedure cancella;
  42.   public
  43.     { Déclarations publiques }
  44.   end;
  45.  
  46. var
  47.   Form1: TForm1;
  48.  
  49. implementation
  50.  
  51. {$R *.dfm}
  52.  
  53. procedure TForm1.FormCreate(Sender: TObject);
  54. begin
  55.   Form1.Caption:='Interessi composti';
  56.   LabeledEditRendimentoPercentuale.ReadOnly:=true;
  57.   LabeledEditSommaIniziale.ReadOnly:=true;
  58.   LabeledEditRendimentoMensile.ReadOnly:=true;
  59.   MemoElencoAnnuale.ReadOnly:=true;
  60.   cancella;
  61. end;
  62.  
  63. procedure TForm1.cancella;
  64. begin
  65.   LabeledEditRendimentoPercentuale.Text:='';
  66.   LabeledEditSommaIniziale.Text:='';
  67.   LabeledEditRendimentoMensile.Text:='';
  68.   LabelSommaFinale.Caption:='';
  69.   MemoElencoAnnuale.Lines.Clear;
  70.   SpinEditAnni.Value:=0;
  71. end;
  72.  
  73. procedure TForm1.ButtonCancellaClick(Sender: TObject);
  74. begin
  75.  cancella;
  76. end;
  77.  
  78. procedure TForm1.LabeledEditRendimentoPercentualeKeyPress(Sender: TObject;
  79.   var Key: Char);
  80. begin
  81.   LabeledEditRendimentoPercentuale.Text:=tasto(LabeledEditRendimentoPercentuale.Text, Key);
  82. end;
  83.  
  84. procedure TForm1.LabeledEditSommaInizialeKeyPress(Sender: TObject;
  85.   var Key: Char);
  86. begin
  87.   LabeledEditSommaIniziale.Text:=tasto(LabeledEditSommaIniziale.Text, Key);
  88. end;
  89.  
  90. procedure TForm1.LabeledEditRendimentoMensileKeyPress(Sender: TObject;
  91.   var Key: Char);
  92. begin
  93.   LabeledEditRendimentoMensile.Text:=tasto(LabeledEditRendimentoMensile.Text, Key);
  94. end;
  95.  
  96. procedure TForm1.ButtonCalcolaClick(Sender: TObject);
  97. var i,fine:integer;
  98.     somma,percentuale,rendimento:double;
  99. begin
  100.   fine:=SpinEditAnni.Value;
  101.   somma:=StrToFloatDef(LabeledEditSommaIniziale.Text, 0.0);
  102.   percentuale:=1.0+(StrToFloatDef(LabeledEditRendimentoPercentuale.Text, 0.0)/100.0);
  103.   rendimento:=StrToFloatDef(LabeledEditRendimentoMensile.Text, 0.0);
  104.   MemoElencoAnnuale.Lines.Clear;
  105.   for i:=1 to fine do
  106.   begin
  107.     somma:=rendimento+somma*percentuale;
  108.     MemoElencoAnnuale.Lines.Add(format('%3d ->%12.2f €',[i, somma]));
  109.   end;
  110.   LabelSommaFinale.Caption:='Somma finale: '+#13+#10+format('%0.2f €', [somma]);
  111. end;
  112.  
  113. procedure TForm1.LabeledEditSommaInizialeKeyDown(Sender: TObject;
  114.   var Key: Word; Shift: TShiftState);
  115. begin
  116.   if Key=46 then
  117.      LabeledEditSommaIniziale.Text:='';
  118. end;
  119.  
  120. procedure TForm1.LabeledEditRendimentoPercentualeKeyDown(Sender: TObject;
  121.   var Key: Word; Shift: TShiftState);
  122. begin
  123.   if Key=46 then
  124.     LabeledEditRendimentoPercentuale.Text:='';
  125. end;
  126.  
  127. procedure TForm1.LabeledEditRendimentoMensileKeyDown(Sender: TObject;
  128.   var Key: Word; Shift: TShiftState);
  129. begin
  130.   if Key=46 then
  131.     LabeledEditRendimentoMensile.Text:='';
  132. end;
  133.  
  134. end.