PROGRAM APLIKASI
MENGHITUNG PERPANGKATAN BILANGAN
- FORM
Adapun gambar dari form program aplikasinya seperti di bawah ini :
- SCRIPT CODE (LISTING PROGRAM)
Adapun Script (listing program aplikasinya) dapat dilihat di bawah ini :
unit Unit1;
interface
uses
Windows,
Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,
StdCtrls;
type
TForm1 =
class(TForm)
GroupBox1:
TGroupBox;
Label4: TLabel;
Label5: TLabel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
cmd_p1:
TButton;
cmd_p2:
TButton;
cmd_p3:
TButton;
cmd_p4:
TButton;
txt_hasil:
TEdit;
txt_pangkat:
TEdit;
txt_bil: TEdit;
Button1:
TButton;
Button2:
TButton;
Label6: TLabel;
procedure
cmd_p1Click(Sender: TObject);
procedure
cmd_p2Click(Sender: TObject);
procedure
cmd_p3Click(Sender: TObject);
procedure
cmd_p4Click(Sender: TObject);
private
{ Private
declarations }
public
{ Public
declarations }
procedure pangkat_1 (p,l:string);
function
pangkat_2 (p,l:string):string;
function
pangkat_3 (m,n:integer):integer;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.cmd_p1Click(Sender: TObject);
var
a,b,c,l:Integer;
begin
l:=1;
c:=1;
a:=StrToInt(txt_pangkat.Text);
b:=StrToInt(txt_bil.Text);
while l<=a
do
begin
c:=c*b;
l:=l+1;
end;
txt_hasil.Text:=
IntToStr(c);
end;
procedure TForm1.pangkat_1(p,l:string);
var
a,b,l:integer;
begin
l:=1;
c:=1;
a:=StrToInt(p);
b:=StrToInt(l);
while
begin
c:=c*b;
l:=l+1;
end;
txt_hasil.Text:= IntToStr(c);
end;
function Tform1.pangkat_2(p,l:string):string;
var
a,b,l:integer;
begin
l:=1;
c:=1;
a:=StrToInt(p);
b:=StrToInt(l);
while
l<= a do
begin
c:=c*b;
l:=l+1;
end;
pangkat_2:=IntToStr(c);
end;
function TForm1.pangkat_3(m,n:integer):Integer;
var
a,b,l:Integer;
begin
l:=1;
c:=1;
while
l<= n do
begin
c:=c*m;
l:=l+1;
end;
pangkat_3:=c;
end;
end;
procedure TForm1.cmd_p2Click(Sender: TObject);
begin
pangkat_1(txt_pangkat.Text,txt_bil.Text);
end;
procedure TForm1.cmd_p3Click(Sender: TObject);
begin
txt_hasil.Text:=pangkat_2(txt_pangkat.Text,txt_bil.Text);
end;
procedure TForm1.cmd_p4Click(Sender: TObject);
var
A,B,C:integer;
begin
A:=
StrToInt(txt_bil.Text);
B:=
StrToInt(txt_pangkat.Text);
C:=
pangkat_3(A,B);
txt_hasil.Text:=IntToStr(C);
end;
end. - FORM RUNNING PROGRAM
Adapun gambar dari form running program aplikasinya seperti di bawah ini :
0 komentar:
Posting Komentar