Sabtu, 08 Desember 2012
PROGRAM STATISTIKA MENGGUNAKAN DELPHI (ARRAY)
procedure TForm1.Button1Click(Sender: TObject);
begin
ListBox1.Items.Add(Edit1.Text);
Edit1.Text:='';
end;
procedure TForm1.Button2Click(Sender: TObject);
var n,i:integer; a:array[1..10]of integer;
begin
i:=1;
for i:=1 to ListBox1.Items.Count do
begin
a[i]:=strtoint(ListBox1.Items[i-1]);
end;
n:=strtoint(Edit2.Text);
Edit3.Text:=inttostr(a[n]);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Edit2.Text:='';
Edit3.Text:='';
Edit4.Text:='';
Edit5.Text:='';
Edit6.Text:='';
Edit7.Text:='';
ListBox1.Items.Clear;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
Edit4.Text:=inttostr(ListBox1.Items.Count);
end;
procedure TForm1.Button6Click(Sender: TObject);
var a:array[1..10]of integer; i,jumlah:integer;
begin
i:=1;
jumlah:=0;
for i:=1 to ListBox1.Items.Count do
begin
a[i]:=strtoint(ListBox1.Items[i-1]);
jumlah:=jumlah+a[i];
end;
Edit5.Text:=inttostr(jumlah);
end;
procedure TForm1.Button7Click(Sender: TObject);
var a:array[1..10]of integer; i,n:integer;
begin
i:=1;
n:=ListBox1.Items.Count;
begin
for i:=1 to n do
a[i]:=strtoint(ListBox1.Items[i-1]);
for i:=0 to n do
if a[i]>=a[i-1] then Edit6.Text:=inttostr(a[i])
else Edit6.Text:=inttostr(a[i-1]);
end;
end;
procedure TForm1.Button8Click(Sender: TObject);
var n,i,jumlah:integer; rata:real; a:array[1..10]of integer;
begin
n:=ListBox1.Items.Count;
i:=1;
jumlah:=0;
for i:=1 to n do
begin
a[i]:=strtoint(ListBox1.Items[i-1]);
jumlah:=jumlah+a[i];
end;
rata:=jumlah/n;
Edit7.Text:=floattostr(rata);
end;
procedure TForm1.Button9Click(Sender: TObject);
var a:array[1..10]of integer; i,n:integer;
begin
i:=1;
n:=ListBox1.Items.Count;
begin
for i:=1 to n do
a[i]:=strtoint(ListBox1.Items[i-1]);
for i:=0 to n do
if a[i]>=a[i-1] then Edit6.Text:=inttostr(a[i])
else Edit1.Text:=inttostr(a[i-1]);
end;
end;
end.
Langganan:
Posting Komentar (Atom)

Tidak ada komentar:
Posting Komentar
Silakan meninggalkan komentar ^_^