Minggu, 21 Juni 2015

Menggunakan Program perpangkatan
















List Program 1
List Program 2

List Program
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    btnPANGKAT1: TButton;
    btnPANGKAT2: TButton;
    btnPANGKAT3: TButton;
    btnPANGKAT4: TButton;
    btnCLEAR: TButton;
    procedure btnPANGKAT1Click(Sender: TObject);
    procedure btnPANGKAT2Click(Sender: TObject);
    procedure btnPANGKAT3Click(Sender: TObject);
    procedure btnPANGKAT4Click(Sender: TObject);
    procedure btnCLEARClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure pangkat1(p,l:string);
    function pangkat2(p,l:string):string;
    function pangkat3(m,n:integer):integer;
  end;

var
  Form1: TForm1;
  c:integer;

implementation

{$R *.dfm}

procedure TForm1.btnPANGKAT1Click(Sender: TObject);
var
  a,b,i,c:integer;
begin
  i:=1;
  c:=1;
  a:=strtoint(edit2.Text);
  b:=strtoint(edit1.Text);
  while i<=a do
  begin
    c:=c*b;
    i:=i+1;
  end;
  edit3.Text:=inttostr(c);
end;

procedure TForm1.pangkat1(p,l:string);
var
  a,b,i:integer;
begin
  i:=1;
  c:=1;
  a:=strtoint(p);
  b:=strtoint(l);
  while i<=a do
  begin
    c:=c*b;
    i:=i+1;
  end;
  edit3.Text:=inttostr(c);
end;

function TForm1.pangkat2(p,l:string):string;
var
  a,b,i:integer;
begin
  i:=1;
  c:=1;
  a:=strtoint(p);
  b:=strtoint(l);
  while i<=a do
  begin
    c:=c*b;
    i:=i+1;
  end;
  pangkat2:=inttostr(c);
end;

function TForm1.pangkat3(m,n:integer):integer;
var
  i:integer;
begin
  i:=1;
  c:=1;
  while i<=n do
  begin
    c:=c*m;
    i:=i+1;
  end;
  pangkat3:=c;
end;

procedure TForm1.btnPANGKAT2Click(Sender: TObject);
begin
  pangkat1(edit2.Text,edit1.Text);
end;

procedure TForm1.btnPANGKAT3Click(Sender: TObject);
begin
  edit3.Text:=pangkat2(edit2.Text,edit1.Text);
end;

procedure TForm1.btnPANGKAT4Click(Sender: TObject);
var
  a,b,c:integer;
begin
  a:=strtoint(edit1.Text);
  b:=strtoint(edit2.Text);
  c:=pangkat3(a,b);
  edit3.Text:=inttostr(c);
end;

procedure TForm1.btnCLEARClick(Sender: TObject);
begin
  edit1.Text:='';
  edit2.Text:='';
  edit3.Text:='';
end;

end.


Hasil Running






















0 komentar:

Posting Komentar

Categories

Total Tayang

Jam

Kalender Islam

Diberdayakan oleh Blogger.

Popular Posts

Pengikut