Tuesday, January 11, 2011

0

project statistika (DELPHI 7)

Posted in
........................STATISTIKA...................................

procedure TForm1.Button1Click(Sender: TObject); //>>
begin
with ListBox1.Items do
Add(Edit1.Text);
Edit1.Text:='';
end;

procedure TForm1.Button3Click(Sender: TObject); //SELESAI
begin
  close;
end;

procedure TForm1.Button4Click(Sender: TObject); //BANYAK DATA
begin
Edit2.Text:=IntToStr(ListBox1.Items.Count);
end;

procedure TForm1.Button5Click(Sender: TObject); //JUMLAH
var A:array[0..100] of Integer;
    i,jml:Integer;
begin
    for i:=0 to ListBox1.Items.Count-1 do
    A[i]:=StrToInt(ListBox1.Items[i]);
    jml:=0;
    for i:=0 to ListBox1.Items.Count-1 do
    jml:=jml+A[i];
    Edit3.Text:=IntToStr(jml);
end;


procedure TForm1.Button8Click(Sender: TObject); //MIN
var A:array[0..100] of Integer;
    i,M:Integer;
begin
    for i:=0 to ListBox1.Items.Count-1 do
    A[i]:=StrToInt(ListBox1.Items[i]);
    M:=A[0];
    for i:=0 to ListBox1.Items.Count-1 do
    If M>A[i] then M:=A[i];
    Edit6.Text:=IntToStr(M);
end;

procedure TForm1.Button6Click(Sender: TObject); //RATA-RATA
var A:array[0..100] of Integer;
    i,jml,n:Integer;
    z:Real;
begin
    for i:=0 to ListBox1.Items.Count-1 do
    A[i]:=StrToInt(ListBox1.Items[i]);
    jml:=0;
    for i:=0 to ListBox1.Items.Count-1 do
    jml:=jml+A[i];
    n:=ListBox1.Items.Count;
    z:=jml/n;
    Edit4.Text:=FloatToStr(z);

end;

procedure TForm1.Button7Click(Sender: TObject);//MAX
var A:array[0..100] of Integer;
    i,N:Integer;
begin
    for i:=0 to ListBox1.Items.Count-1 do
    A[i]:=StrToInt(ListBox1.Items[i]);
    N:=A[0];
    for i:=0 to ListBox1.Items.Count-1 do
    If N<A[i] then N:=A[i];
    Edit5.Text:=IntToStr(N);
end;


procedure TForm1.Button9Click(Sender: TObject); //JANGKAUAN
Var x,y,z:integer;
begin
x:=strtoint(edit5.text);
y:=strtoint(edit6.text);
z:=x-y;
edit7.Text:=inttostr(z);
end;

procedure TForm1.Button11Click(Sender: TObject);  //MEDIAN
var
  a: array [0..100] of Integer;
  i,jml,k:Integer;
  l,m,o:Integer;
  n:Real;
begin
  k:=StrToInt(edit2.text) div 2;
  l:=StrToInt(edit2.text) mod 2;
  if l=0 then
  begin
    m:=k;
    n:=(StrToFloat(ListBox2.Items[m])+StrToInt(ListBox2.Items[k-1]))/2;
    Edit5.Text:=FloatToStr(n);
  end
  else
  begin
  o:=StrToInt(listBox2.Items[k]);
  Edit8.Text:=IntToStr(o);

end;
end;

procedure TForm1.Button10Click(Sender: TObject);  //DATA TERURUT
var A:array[0..100] of Integer;
    i,j,k:Integer;
begin
    for i:=0 to ListBox1.Items.Count-1 do
    A[i]:=StrToInt(ListBox1.Items[i]);
    for i:=0 to ListBox1.Items.Count-1 do
    for j:=0 to i do
    if A[i]<A[j]
    then begin
    k:=A[i];
    A[i]:=A[j];
    A[j]:=k;
    end;
    for i:=0 to ListBox1.Items.Count-1 do
    ListBox2.Items.Add(IntToStr(A[i]));
end;


procedure TForm1.Button2Click(Sender: TObject);  //HAPUS
begin
 edit1.clear;edit2.Clear;edit3.clear;edit4.Clear;
 edit5.Clear; edit6.clear;edit7.Clear;edit8.clear;
 edit9.Clear;
 listbox1.Clear;listbox2.Clear;
end;

procedure TForm1.Button12Click(Sender: TObject);  //MODUS
var
  p,q,s,r,i,jml,jml2:integer;

begin
    r:=strtoint(edit2.Text);
    jml:=0;
    jml2:=0;
    p:=strtoint(listbox2.Items[0]);
  for i:=0 to r-2 do
  begin
    q:=strtoint(listbox2.Items[i+1]);
    if p=q then
    begin
      jml:=jml+1;
    end
    else
    begin
       jml2:=jml;
       jml:=0;
       p:= strtoint(listbox2.Items[i+1]);
    end;

if jml>jml2 then
  begin
    s:=strtoint(listbox2.Items[i]);
  end

  end ;
  edit9.Text:=inttostr(s);

end;

end.

0 comments: