unit ufunction;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Editx: TEdit;
    Label2: TLabel;
    Edity: TEdit;
    calculate: TButton;
    exit: TButton;
    procedure calculateClick(Sender: TObject);
    procedure exitClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.calculateClick(Sender: TObject);
var
   x,y:real;
begin
   x:=strtofloat(editx.text);
   if x>=0 then
   y:=x+1
   else
   y:=1-2*x;
   edity.Text:=floattostr(y);

end;

procedure TForm1.exitClick(Sender: TObject);
begin
close
end;

end.
