Minggu, 21 Juni 2015

TUGAS - REKURSI

TUGAS - REKURSI


unit procedurefunctiontugasjadi;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  Tpangkat = class(TForm)
    txta: TEdit;
    txtb: TEdit;
    txtc: TEdit;
    txtd: TEdit;
    Button1: TButton;
    A: TLabel;
    B: TLabel;
    C: TLabel;
    D: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    function pangkat(o,p:integer):integer;
  end;
var
  pangkat: Tpangkat;
implementation
{$R *.dfm}
function Tpangkat.pangkat(o,p:integer):integer;
var
  i,c:integer;
begin
  i:=1;
  c:=1;
  while i<=p do
  begin
    c:=c*o;
    i:=i+1;
  end;
  pangkat:=c;
end;
procedure Tpangkat.Button1Click(Sender: TObject);
var
  A2,B3,C3,A,B,C:integer;
  D:real;
begin
  A:=strtoint(txtA.Text);
  B:=strtoint(txtB.Text);
  C:=strtoint(txtC.Text);

  A2:=pangkat(A,2);
  B3:=pangkat(B,3);
  C3:=pangkat(C,3);

  D:=(A2+B3)/C3;
  txtD.Text:=floattostr(D);end;
end.
 


0 komentar:

Posting Komentar