Sabtu, 19 November 2016

Program Statistika Menggunakan Delphi

procedure TStatistika.Button1Click(Sender: TObject);
begin
listbox1.Items.Add(edit1.text);
edit1.Text:=' ';
end;

procedure TStatistika.Button2Click(Sender: TObject);
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 TStatistika.Button3Click(Sender: TObject);
var m,i,z,max,min:integer;
    a:array[1..100] of integer;
begin
  z:=listbox1.items.Count;
  edit2.Text:=inttostr(z);


end;

procedure TStatistika.Button4Click(Sender: TObject);
var m,i,z,max,min:integer;
    a:array[1..100] of integer;
begin
  z:=listbox1.items.Count;

  for i:= 1 to z do
  a[i]:= strtoint(listbox1.items[i-1]);
  m:=0;

  for i:= 1 to z do
  m:=m+a[i];
  edit3.text:=inttostr(m);
end;



procedure TStatistika.Button5Click(Sender: TObject);
var m,i,z,max,min:integer;
    a:array[1..100] of integer;
begin
  z:=listbox1.items.Count;

  for i:= 1 to z do
  a[i]:= strtoint(listbox1.items[i-1]);
  m:=0;

  for i:= 1 to z do
  m:=m+a[i];

  max:=-2147483647;
  for i:=1 to z do
    if max<a[i] then max:=a[i];
  Edit4.Text:=IntToStr(max);
end;




procedure TStatistika.Button6Click(Sender: TObject);
var m,i,z,max,min:integer;
    a:array[1..100] of integer;
begin
  z:=listbox1.items.Count;

  for i:= 1 to z do
  a[i]:= strtoint(listbox1.items[i-1]);
  m:=0;

  min:=2147483647;
  for i:=1 to z do
    if min>a[i] then min:=a[i];
  edit5.text:=inttostr(min);

end;



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


end;

procedure TStatistika.Button10Click(Sender: TObject);
Var
A:array[0..100] of real;
c,e,n,i,q:integer;
d,f:real;
begin
n:=listbox2.count;
q:=strtoint(edit9.text);
For i:=1 to n do a[i]:=strtofloat(listbox2.Items[i-1]);


c:=(n+1)*q;
d:=c/4;
e:=c div 4;
f:=d-e;

edit10.Text:=floattostr((f*(a[e+1]-a[e]))+a[e]);


end;

procedure TStatistika.Button11Click(Sender: TObject);
Var
A:array[0..100] of real;
c,e,n,h,l,i,q:integer;
d,f,m,k:real;
begin
n:=listbox2.count;
For i:=1 to n do a[i]:=strtofloat(listbox2.Items[i-1]);


c:=(n+1);
d:=c/4;
e:=c div 4;
f:=d-e;

h:=(n+1)*3;
k:=h/4;
l:=h div 4;
m:=k-l;

edit11.text:=floattostr(((m*(a[l+1]-a[l]))+a[l])-((f*(a[e+1]-a[e]))+a[e]));


end;

procedure TStatistika.Button7Click(Sender: TObject);
Var A:array[0..100] of Integer;
    i,M,N,O:Integer;
begin
for i:=0 to ListBox1.Items.Count-1 do
    A[i]:=StrToInt(ListBox2.Items[i]);
    M:=A[0];
    N:=A[0];
    for i:=0 to ListBox2.Items.Count-1 do
    If M<A[i] then M:=A[i];
    If N>A[i] then N:=A[i];
    O:=M-N;
    Edit6.Text:=IntToStr(O);
end;




procedure TStatistika.Button12Click(Sender: TObject);
begin
edit1.text:=' ';
listbox1.items.Clear;
listbox2.Items.Clear;
edit2.text:=' ';
edit3.text:=' ';
edit4.text:=' ';
edit5.text:=' ';
edit6.text:=' ';
edit7.text:=' ';
edit9.text:=' ';
edit10.text:=' ';
edit11.text:=' ';
edit12.Text:=' ';
edit13.text:=' ';
edit14.text:=' ';
end;

procedure TStatistika.Button14Click(Sender: TObject);
var
  a: array [0..100] of integer;
  i,jml,N : integer;
  rata,SB, Zigma: real;


begin
  N:= ListBox1.Count-1;

  for i:= 0 to N do
      A[i]:= StrToInt (ListBox1.Items[i]);

  jml:= 0;
  for i:= 0 to N do
  jml:= jml + A[i];

  rata:= jml / ListBox1.Count;

  Zigma :=0;
  for i := 0 to N do
    begin
     Zigma:= (Zigma + Sqr(A[i] - rata));
     SB:= Sqrt (Zigma / N);
  end;
  Edit12.Text:= FloatToStr(SB);


end;

procedure TStatistika.Button15Click(Sender: TObject);
const
  Nmax = 100;
type
  Lrk = array [0..100] of string;
var
  k, N, i : integer;
  A: Lrk;

begin
  N:= ListBox2.Count-1;
  for i := 0 to N do
  begin
  A[i]:= ListBox2.Items[i];
  end;

  k:=StrToInt(Edit13.Text);
  Edit14.Text:= A[k-1];
end;


procedure TStatistika.Timer1Timer(Sender: TObject);
begin
label1.Left:=label1.Left-30;
 if  label1.Left<=-100 then
 label1.Left := 950;
end;

procedure TStatistika.Button13Click(Sender: TObject);
begin
MainMenu.Show;
Statistika.Hide;
end;

end.

1 komentar: