unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
Edit1: TEdit;
Button2: TButton;
PRocedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
Private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
const pi=3.14159;
Implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var r,c,s:real;
Begin
if edit1.text='' then
showmessage('Input is empty, please re-enter!') //If there is no data entered, prompt
else
Begin
r:=strtofloat(edit1.text);
c:=2*pi*r;
s:=pi*sqr(r);
label2.Caption:='The perimeter of the circle is:'+floattostr(c)+chr(13)+'The area is:'+floattostr(s); //Show the result
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
Begin
form1.Close; //Event button event code
end;
end.