TUGAS
PROCEDURE & FUNCTION
- FORM
- SCRIPT CODE (LISTING PROGRAM)
unit
tugas4;
interface
uses
Windows, Messages, SysUtils, Variants,
Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
GroupBox1: TGroupBox;
Label1: TLabel;
txtA: TEdit;
Label2: TLabel;
txtB: TEdit;
Label3: TLabel;
txtC: TEdit;
Label4: TLabel;
txtD: TEdit;
Button1: TButton;
Label5: TLabel;
Label6: TLabel;
procedure Button1Click(Sender:
TObject);
private
{ Private declarations }
public
{ Public declarations }
function
pangkat(x,y:integer):integer;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TForm1.pangkat(x,y:integer):integer;
var
i,c:integer;
begin
i:=1;
c:=1;
while i<=y do
begin
c:=c*x;
i:=i+1;
end;
pangkat:=c;
end;
procedure TForm1.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.- FORM RUNNING PROGRAM
0 komentar:
Posting Komentar