Hai teman - teman semua.. ngeblog lagi neh guys karena ada tugas
tugas kali ini tentang deret lagi
yuk langsung aja kita coba programnya... gausah panjang lebar yha guys...
1. Buat tampilan interface berikut
2. ini syntaxnya
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;
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.
3. kalo udah, yuk langsung aja kita coba guys...
Tidak ada komentar:
Posting Komentar