Minggu, 30 Oktober 2016

Program Delphi Untuk Mencetak Deret Aritmatika

procedure TDeretAritmatika.Button1Click(Sender: TObject);
var i, n, x, b : integer;
un:real;
begin
x := strtoint(edit1.text);
b := strtoint(edit2.text);
n := strtoint(edit3.Text);
if n > 0 then
begin
un:=x+((n-1)*b);
for i:= 1 to n do
begin
Listbox1.Items.Add(format('Suku ke-%3d : %4d',[i,x]));
x := x + b;


end;
end;
end;



procedure TDeretAritmatika.Button3Click(Sender: TObject);
var
n,x,b:integer;
un,sn:real;
begin
x := strtoint(edit1.text);
b := strtoint(edit2.Text);
n := strtoint(edit3.Text);
if n > 0 then
begin
un:=x+((n-1)*b);
sn:= n*(x+un)/2;
edit4.text:=floattostr(sn);
end;



end;

procedure TDeretAritmatika.Button2Click(Sender: TObject);
begin
edit1.text:=' ';
edit2.text:=' ';
edit3.text:=' ';
edit4.text:=' ';
listbox1.Items.clear;

end;

procedure TDeretAritmatika.Button4Click(Sender: TObject);
begin
Deret.Show;
DeretAritmatika.Hide;
end;

procedure TDeretAritmatika.Timer1Timer(Sender: TObject);
begin
label4.Left:=label4.Left-30;
 if  label4.Left<=-150 then
 label4.Left := 500;

end;

0 komentar:

Posting Komentar