Sabtu, 05 Mei 2012

Tugas Delphi dari M. Ali Rusdi
Berikut adalah listing program dari for to do, for down to do, while do, repeat until.
Ini adalah listingnya :

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    fortodo: TButton;
    fordowntodo: TButton;
    whiledo: TButton;
    repeatuntil: TButton;
    btpangkat: TButton;
    keluar: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    procedure fortodoClick(Sender: TObject);
    procedure fordowntodoClick(Sender: TObject);
    procedure whiledoClick(Sender: TObject);
    procedure repeatuntilClick(Sender: TObject);
    procedure btpangkatClick(Sender: TObject);
    procedure keluarClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

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;
label1.Caption:=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;

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.btpangkatClick(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:=edit1.Text else
begin
for a:=2 to pangkat do
hasil:=hasil*bil;
edit3.Text:=inttostr(hasil);
end;
end;
procedure TForm1.keluarClick(Sender: TObject);
begin
close;
end;

end.




ini adalah lay out dari listing program di atas :

Terima Kasih.......

Bisnis Online 100% gratis

Bisnis 100% Tanpa Modal

Recent Comments