List Program
unit tugas4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
txtA: TEdit;
txtB: TEdit;
txtC: TEdit;
txtD: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Button1: TButton;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: 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.
Listing Program 1 |
Listing Program 2 |
Hasil Running |
Bilangan B adalah berpangkat 3
Bilangan C adalah berpangkat 3
Bilangan D adalah hasil pengoperasian
0 komentar:
Posting Komentar