Minggu, 06 Mei 2012

Program Delphi 1


Tugas 4 Program Delphi

Procedure TForm1.fortodoClick(Sender:TObject);
Var
i,j:integer;b:string;
begin
b:=’’;j:=2;
for i:=1 to 10 do
begin
b:=b+inttostr(j)+’ ’;
j:=j+2;
end;
label1Caption:=b;
end;
procedure TForm1.fordowntodoClick(Sender:TObject);
Var
I,j:integer;b:string;
begin
b:=’’;j:=2;
For  i:=10 downto 1  do;
begin
b:=b+inttostr(i)+’ ‘;
j:=j+2;
end;
label2.caption:=b;
end;
Label2.Caption:=b;
End;
Procedure TForm1.whiledoClick(sender:Tobject);
Var
i,j:integer;b:string;
begin
i:=1;
b:=’’;
while i<=10 do
begin
b:=b+inttostr(i)+’ ’;
i:=i+1;
end;
label3.Caption:=b;
end;
Procedure TForm1.repeatuntilClick(sender:Tobject);
Var
i;j:integer;b:string;
begin
i:=1;
b:=’’;
repeat
b:=b+inttostr(i)+’ ’;
i:=i+1;
until i>10;
label4.Caption:=b;
end;

procedure TForm1.KeluarClick(sender:Tobject);
begin
close;
end;

procedure TForm1.PangkatClick(sender:Tobject);
Var
Bil,hasil,pangkat,a:integer;
Begin
Bil:=strtoint(edit1.Text);
Hasil:=bil;
Pangkat:=strtoint(edit2.Text);
If edit2.Text=’0’ then edit3.Text:=’1’else
If edit2.Text=’1’ then edit3.Text:=’1’Text else
Begin
For a:=2 to pangkat do
Hasil:=hasil*bil;
edit3.Text:=inttostr(hasil);
end;
end.

Hasil Print Screen :

Tidak ada komentar:

Posting Komentar