Tuesday, January 11, 2011

0

prokom rada jangar

Posted in
........ALJABAR HIMPUNAN..........
LISTBOX1=INPUT DATA A, LISTBOX2=AnB,
LISTBOX3=AUB, LISTBOX4=A+B, LISTBOX5=A-B
LISBOX6=INPUTB

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

procedure TForm1.Button7Click(Sender: TObject); //HAPUS
begin
edit1.Clear; edit2.Clear;
listbox1.Clear; listbox2.Clear; listbox3.Clear; listbox4.Clear;
listbox5.Clear; listbox6.Clear;

end;

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


procedure TForm1.Button6Click(Sender: TObject); //<<
begin
with ListBox6.Items do
Add(Edit2.Text);
Edit2.Text:='';
 end;
procedure TForm1.Button2Click(Sender: TObject);//AnB
Var i,j:Integer;
    A,B:Array[0..10] of String;
begin
    For i:=0 to ListBox1.Items.Count-1 do
    A[i]:=ListBox1.Items[i];
    For j:=0 to ListBox6.Items.Count-1 do
    B[j]:=ListBox6.Items[j];
    For i:=0 to ListBox1.Items.Count-1 do
    begin
    For j:=0 to ListBox6.Items.Count-1 do
    if A[i]=B[j] then ListBox2.Items.Add(A[i]);
    end;
    end;

procedure TForm1.Button3Click(Sender: TObject); //AUB
Var i,j:Integer;
    A,B:Array[0..100] of String;
    ada:Boolean;
begin
    For i:=0 to ListBox1.Items.Count-1 do
    A[i]:=ListBox1.Items[i];
    For j:=0 to ListBox6.Items.Count-1 do
    B[j]:=ListBox6.Items[j];
    For i:=0 to ListBox1.Items.Count-1 do
    ListBox3.Items.Add(A[i]);
    For j:=0 to ListBox6.Items.Count-1 do
    begin
    ada:=false;
    For i:=0 to ListBox1.Items.Count-1 do
    if A[i]=B[j] then ada:=true;
    if ada=false then ListBox3.Items.Add(B[j]);
end;
end;
procedure TForm1.Button4Click(Sender: TObject); //A+B
Var i,j:Integer;
    A,B:Array[0..100] of String;
    ada:Boolean;
begin
    For i:=0 to ListBox1.Items.Count-1 do
    A[i]:=ListBox1.Items[i];
    For j:=0 to ListBox6.Items.Count-1 do
    B[j]:=ListBox6.Items[j];
    For i:=0 to ListBox1.Items.Count-1 do
    begin
    ada:=false;
    For j:=0 to ListBox6.Items.Count-1 do
    if A[i]=B[j] then ada:=true;
    if ada=false then ListBox4.Items.Add(A[i]);
    end;
    For j:=0 to ListBox6.Items.Count-1 do
    begin
    ada:=false;
    For i:=0 to ListBox1.Items.Count-1 do
    if A[i]=B[j] then ada:=true;
    if ada=false then ListBox4.Items.Add(B[j]);
end;
end;


procedure TForm1.Button5Click(Sender: TObject); //A-B
Var i,j:Integer;
    A,B:Array[0..100] of String;
    ada:Boolean;
begin
    For i:=0 to ListBox1.Items.Count-1 do
    A[i]:=ListBox1.Items[i];
    For j:=0 to ListBox6.Items.Count-1 do
    B[j]:=ListBox6.Items[j];
    For i:=0 to ListBox1.Items.Count-1 do
    begin
    ada:=false;
    For j:=0 to ListBox6.Items.Count-1 do
    if A[i]=B[j] then ada:=true;
    if ada=false then ListBox5.Items.Add(A[i]);
end;
end;
end.

.........BIL. PRIM ATAU BUKAN.........
EDIT1=MASUKAN, EDIT 2= KETERANGAN

procedure TForm1.Button1Click(Sender: TObject);
var n,i,s:integer;
    p:boolean;
begin
    n:=StrToInt(Edit1.Text);
    i:=2;
    P:=True ;
    while (i<=n-1) and p do
    begin
    s:=n mod i;
    if s=0 then p:=false;
    i:=i+1;
    end;

    if p=true
    then Edit2.Text:='  Bilangan Prima'
    else Edit2.Text:='  Bilangan Komposit';
    if n=1
    then Edit2.Text:='  Bilangan Komposit';
    if n=0
    then Edit2.Text:='  Bilangan Komposit';
end;


end.

.......BILANGAN PRIMA SEBANYAK n......
EDIT1=MASUKAN,LISTBOX1=KELUARAN

procedure TForm1.Button1Click(Sender: TObject);
var i,a,b,c,d:integer;
            p:boolean;
begin
    a:=StrToInt(Edit1.Text);
    For b:=2 to 1000 do
    begin
    i:=2;
    p:=true;
    while(i<=b-1)and p do
       begin
       c:=b mod i;
       if c=0 then p:=false;
       i:=i+1;
       end;
    if Listbox1.Items.count<a then
    if p=true then
    Listbox1.Items.Add('Bilangan Prima ke-'+IntToStr(Listbox1.Items.count+1)+'='+IntToStr(b));
    end;
end;


end.

..............DEKOMPOSISI BILANGAN N.........

procedure TForm1.Button1Click(Sender: TObject);
var i,a,b:integer;
        k:real;
begin
    a:=StrToInt(Edit1.Text);
    i:=2;
    b:=a;
    while i<=a do
    begin
    if b mod i=0
    then
    begin
    Listbox1.Items.Add(IntToStr(i));
    k:=b/i;
    b:=trunc(k);
    end
    else i:=1+i;
    end;

end;

end.

........FIBONACCI..........

procedure TForm1.Button1Click(Sender: TObject);
Var i,n,a,b,c:Integer;
begin
   n:=StrToInt(Edit1.Text);
   a:=1;
   b:=1;
   ListBox1.Items.Add('Bil.Fibonacci ke-1=1');
   ListBox1.Items.Add('Bil.Fibonacci ke-2=1');
   for i:=3 to n do
   begin
   c:=a+b;
   ListBox1.Items.Add('Bil.Fibonacci ke-'+IntToStr(i)+'='+IntToStr(c));
   a:=b;
   b:=c;
   end;
end;


END.

....KONVER UANG......
COMBOBOX1=INPUT, COMBOX2=OUT


procedure TForm1.Button1Click(Sender: TObject);
var x:real;
begin
x := strtofloat(Edit1.Text);

if (combobox1.Text='RUPIAH') and (combobox2.Text='DOLLAR (US)')
then edit2.Text:= floattostr(x/9000);
 if (combobox1.Text='RUPIAH') and (combobox2.Text='RUPIAH')
then edit2.Text:= floattostr(x/1);
if (combobox1.Text='DOLLAR (US)') and (combobox2.Text='RUPIAH')
then edit2.Text:= floattostr(x*9000);

if (combobox1.Text='RUPIAH') and (combobox2.Text='DOLLAR (SINGAPURA)')
then edit2.Text:= floattostr(x/6619);
if (combobox1.Text='DOLLAR (SINGAPURA)') and (combobox2.Text='RUPIAH')
then edit2.Text:= floattostr(x*6619);

if (combobox1.Text='RUPIAH') and (combobox2.Text='EURO')
then edit2.Text:= floattostr(x/13650);
if (combobox1.Text='EURO') and (combobox2.Text='RUPIAH')
then edit2.Text:= floattostr(x*13650);

if (combobox1.Text='RUPIAH') and (combobox2.Text='POUND (INGGRIS)')
then edit2.Text:= floattostr(x/17076);
if (combobox1.Text='POUND (INGGRIS)') and (combobox2.Text='RUPIAH')
then edit2.Text:= floattostr(x*17076);

if (combobox1.Text='DOLLAR (US)') and (combobox2.Text='DOLLAR (SINGAPURA)')
then edit2.Text:= floattostr(x/0.6994);
 if (combobox1.Text='DOLLAR (US)') and (combobox2.Text='DOLLAR (US)')
then edit2.Text:= floattostr(x/1);
if (combobox1.Text='DOLLAR (SINGAPURA)') and (combobox2.Text='DOLLAR (US)')
then edit2.Text:= floattostr(x*0.6994);

if (combobox1.Text='DOLLAR (US)') and (combobox2.Text='EURO')
then edit2.Text:= floattostr(x/1.4422);
if (combobox1.Text='EURO') and (combobox2.Text='DOLLAR (US)')
then edit2.Text:= floattostr(x*1.4422);

if (combobox1.Text='DOLLAR (US)') and (combobox2.Text='POUND (INGGRIS)')
then edit2.Text:= floattostr(x/1.8041);
if (combobox1.Text='POUND (INGGRIS)') and (combobox2.Text='DOLLAR (US)')
then edit2.Text:= floattostr(x*1.8041);

if (combobox1.Text='DOLLAR (SINGAPURA)') and (combobox2.Text='EURO')
then edit2.Text:= floattostr(x/2.0618);
if (combobox1.Text='DOLLAR (SINGAPURA)') and (combobox2.Text='DOLLAR (SINGAPURA)')
then edit2.Text:= floattostr(x/1);
if (combobox1.Text='EURO') and (combobox2.Text='DOLLAR (SINGAPURA)')
then edit2.Text:= floattostr(x*2.0618);

if (combobox1.Text='DOLLAR (SINGAPURA)') and (combobox2.Text='POUND (INGGRIS)')
then edit2.Text:= floattostr(x/2.5792);
if (combobox1.Text='POUND (INGGRIS)') and (combobox2.Text='DOLLAR (SINGAPURA)')
then edit2.Text:= floattostr(x*2.5792);

if (combobox1.Text='EURO') and (combobox2.Text='POUND (INGGRIS)')
then edit2.Text:= floattostr(x/1.251);
if (combobox1.Text='EURO') and (combobox2.Text='EURO')
then edit2.Text:= floattostr(x/1);
if (combobox1.Text='POUND (INGGRIS)') and (combobox2.Text='EURO')
then edit2.Text:= floattostr(x*1.251);
if (combobox1.Text='POUND (INGGRIS)') and (combobox2.Text='POUND (INGGRIS)')
then edit2.Text:= floattostr(x/1);


end;

procedure TForm1.Button2Click(Sender: TObject);
begin
application.Terminate;
end;

end.

.........PHYTAGORAS........

procedure TForm1.Button3Click(Sender: TObject);
var n,i,j,k,a,b,c:integer;
begin
  n:=StrToInt(Edit1.Text);
  For i:=1 to n do
  begin
  For j:=1 to i do
    begin
    for k:=1 to j do
      begin
      a:=i*i;
      b:=j*j+k*k;
      if a=b
      then
        begin
        c:=c+1;
        Listbox1.Items.Add('Bilangan Phytagoras-'+IntToStr(c)+':'+IntToStr(k)+','+IntToStr(j)+','+IntToStr(i));
  end;
  end;
  end;
  end;

end;



end.

0 comments: