0% found this document useful (0 votes)
47 views8 pages

Delpi 21 September

The document describes a program with a radio group, three edit boxes, and buttons to perform mathematical operations on values entered in the edit boxes. The radio group is used to select an operator like multiplication, addition, subtraction or division. When a button is clicked, numbers from the edit boxes are converted to floats, the calculation is performed based on the selected operator, and the result is displayed in the third edit box.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views8 pages

Delpi 21 September

The document describes a program with a radio group, three edit boxes, and buttons to perform mathematical operations on values entered in the edit boxes. The radio group is used to select an operator like multiplication, addition, subtraction or division. When a button is clicked, numbers from the edit boxes are converted to floats, the calculation is performed based on the selected operator, and the result is displayed in the third edit box.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

unit Ulatihan7;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, ExtCtrls;

type

TForm1 = class(TForm)

rg1: TRadioGroup;

Edit1: TEdit;

Edit2: TEdit;

Edit3: TEdit;

Button1: TButton;

Button2: TButton;

Button3: TButton;
Label1: TLabel;

procedure rg1Click(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

a,b,c:real;

implementation

{$R *.dfm}

procedure TForm1.rg1Click(Sender: TObject);

begin

if rg1.ItemIndex=0 then

begin

label1.Caption:='X';

edit1.Text:='';

edit2.Text:='';

edit3.Text:='';
end else if rg1.ItemIndex=1 then

begin

label1.Caption:='+';

edit1.Text:='';

edit2.Text:='';

edit3.Text:='';

end else if rg1.ItemIndex=2 then

begin

label1.Caption:='-';

edit1.Text:='';

edit2.Text:='';

edit3.Text:='';

end else if rg1.ItemIndex=3 then

begin

label1.Caption:=':';

edit1.Text:='';

edit2.Text:='';

edit3.Text:='';

end;

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

if rg1.ItemIndex=0 then

begin

a:=strtofloat(edit1.Text);

b:=strtofloat(edit2.Text);
c:=b*a;

edit3.text:=floattostr(c)

end else if rg1.ItemIndex=1 then

begin

a:=strtofloat(edit1.Text);

b:=strtofloat(edit2.Text);

c:=b+a;

edit3.text:=floattostr(c)

end else if rg1.ItemIndex=2 then

begin

a:=strtofloat(edit1.Text);

b:=strtofloat(edit2.Text);

c:=a-b;

edit3.text:=floattostr(c)

end else if rg1.ItemIndex=3 then

begin

a:=strtofloat(edit1.Text);

b:=strtofloat(edit2.Text);

if b=0 then

begin messagedlg('dodol?! 0 tidak bisa untuk membagi',mtwarning,[mbOk],0);

edit1.text:='';

edit2.text:='';

edit3.text:='';

end else

c:=a/b;

edit3.text:=floattostr(c)

end;
end;

procedure TForm1.Button2Click(Sender: TObject);

begin

edit1.text:='';

edit2.text:='';

edit3.text:='';

end;

procedure TForm1.Button3Click(Sender: TObject);

begin

application.Terminate;

end;

end.

Latihan 8
unit Ulatihan8;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, ComCtrls, jpeg, StdCtrls, ExtCtrls;

type

TForm1 = class(TForm)

Button1: TButton;

Button2: TButton;

Button3: TButton;

Panel1: TPanel;

StatusBar1: TStatusBar;

Image1: TImage;

RichEdit1: TRichEdit;
procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

begin

richedit1.Visible:=true;

image1.visible:=false;

richedit1.Lines.LoadFromFile('tulisan.rtf');

end;

procedure TForm1.Button2Click(Sender: TObject);

begin

richedit1.Visible:=false;
image1.visible:=true;

image1.picture.LoadFromFile('bunga.jpg');

end;

procedure TForm1.Button3Click(Sender: TObject);

begin

if messagedlg ('anda yakin akan keluar?',mtconfirmation,mbOkcancel,0)

=mrOk then

application.Terminate;

end;

end.

You might also like