TUGAS
MENGHITUNG HASIL PENJUMLAHAN DERET DUA BILANGAN
- Adapun Script (listing program aplikasinya) dapat dilihat di bawah ini :
unit
deret;
interface
uses
Windows, Messages, SysUtils,
Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label4: TLabel;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
Label5: TLabel;
Label6: TLabel;
Button3: TButton;
Label7: TLabel;
Label8: TLabel;
procedure Button1Click(Sender:
TObject);
procedure Button2Click(Sender:
TObject);
private
{ Private declarations }
public
{ Public declarations }
function
deret(x:integer):integer;
end;
var
Form1: TForm1;
hasil:integer;
D:real;
implementation
{$R *.dfm}
function TForm1.deret(x:integer):integer;
var
i:integer;
begin
i:=1;
hasil:=0;
while i<=x do
begin
hasil:=hasil+i;
i:=i+1;
end;
deret:=hasil;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
DA,DB,DC,A,B,C:integer;
begin
A:=strtoint(Edit1.Text);
B:=strtoint(Edit2.Text);
C:=strtoint(Edit3.Text);
DA:=deret(A);
DB:=deret(B);
DC:=deret(C);
D:=(DA+DB)/DC;
Edit4.Text:=floattostr(D);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
Edit4.Text:='';
end;
end.- FORM RUNNING PROGRAM
0 komentar:
Posting Komentar