Jumat, 06 Mei 2016

Listing Program Laporan Akhir Perulangan Pada Delphi

berikut ini adalah listing program dari laporan akhir perulangan pada Delphi:




var
  Form1: TForm1;
  j,k:integer;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Label1.caption := ‘Perulangan pada Delphi’;
  Label2.caption := ‘J’;
  Label3.caption := ‘K’;
  Edit1.Text := ‘’;
  Edit2.Text := ‘’;
  Button1.caption := ‘For to do’;
  Button2.caption := ‘For downto do’;
  Button3.caption := ‘While do’;
  Button4.caption := ‘Repeat until’;
  Button5.caption := ‘Clear’;
memo1.Clear;
edit1.Text:='1';
edit2.Text:='10';
j:=strtoint(edit1.Text);
k:=strtoint(edit2.Text);
memo1.Lines.Add(string('petunjuk penginputan'));
memo1.Lines.Add(string('--------------------------------------------------------------------'));
memo1.Lines.add(string('1.untuk for to do J harus lebih besar dari K'));
memo1.Lines.add(string(''));
memo1.Lines.add(string('2.untuk for downto do K harus lebih besar dari J'));
memo1.Lines.add(string(''));
memo1.Lines.add(string('3.untuk while do J harus lebih besar dari K'));
memo1.Lines.add(string(''));
memo1.Lines.add(string('4.untuk repeat until J harus lebih besar dari K'));
memo1.Lines.add(string(''));
memo1.Lines.add(string('bila sudah mengerti tekan tombol clear'));
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
j:=strtoint(edit1.Text);
k:=strtoint(edit2.Text);
memo1.Clear;
for j:=j to k do
begin
memo1.Lines.add(inttostr(j));
end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
j:=strtoint(edit1.Text);
k:=strtoint(edit2.Text);
memo1.Clear;
for j:=j downto k do
begin
memo1.Lines.add(inttostr(j));
end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
j:=strtoint(edit1.Text);
k:=strtoint(edit2.Text);
memo1.Clear;
while j<k do
begin
memo1.Lines.add(inttostr(j));
j:=j+1;
end;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
j:=strtoint(edit1.Text);
k:=strtoint(edit2.Text);
memo1.Clear;
repeat
begin
memo1.Lines.add(inttostr(j));
j:=j+1;
end;
until j>k;
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
memo1.Clear;
end;

end.



Tidak ada komentar:

Posting Komentar