Простой калькулятор

unit Unit1;
 
{$mode objfpc}{$H+}
 
interface
 
uses
  Classes, SysUtils, FileUtil, Forms, Controls, 
  Graphics, Dialogs, StdCtrls;
 
type
 
  { TForm_calc }
 
  TForm_calc = class(TForm)
    Button_plus: TButton;
    Button_minus: TButton;
    Button_mult: TButton;
    Button_div: TButton;
    Edit_num1: TEdit;
    Edit_num2: TEdit;
    Label_result: TLabel;
    procedure Button_divClick(Sender: TObject);
    procedure Button_minusClick(Sender: TObject);
    procedure Button_multClick(Sender: TObject);
    procedure Button_plusClick(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;
 
var
  Form_calc: TForm_calc;
 
implementation
 
{$R *.lfm}
 
{ TForm_calc }
 
procedure TForm_calc.Button_plusClick(Sender: TObject);
var a,b,c: real;
begin
   a := strtofloat(Edit_num1.Text);
   b := strtofloat(Edit_num2.Text);
   c := a + b;
   Label_result.Caption := floattostr(c);
end;
 
procedure TForm_calc.Button_minusClick(Sender: TObject);
begin
   Label_result.Caption := floattostr(strtofloat(Edit_num1.Text)-strtofloat(Edit_num2.Text));
end;
 
procedure TForm_calc.Button_divClick(Sender: TObject);
begin
  Label_result.Caption := floattostr(strtofloat(Edit_num1.Text)/strtofloat(Edit_num2.Text));
end;
 
procedure TForm_calc.Button_multClick(Sender: TObject);
begin
    Label_result.Caption := floattostr(strtofloat(Edit_num1.Text)*strtofloat(Edit_num2.Text));
end;
 
end.

Добавить комментарий