Sei sulla pagina 1di 9

KALKULATOR MINI

var
Form1: TForm1;
a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p: real;

begin
m:=strtofloat(akar1.text);
n:=sqrt(m);
akar2.text:=floattostr(n);
end;

implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender:
TObject);
begin
a:=strtofloat(plus1.text);
b:=strtofloat(plus2.text);
c:=a+b;
plus3.text:=floattostr(c);

procedure TForm1.Button6Click(Sender:
TObject);
begin
o:=strtofloat(kuadrat1.text);
p:=sqr(o);
kuadrat2.text:=floattostr(p);
end;
end.

end;
procedure TForm1.Button2Click(Sender:
TObject);
begin
d:=strtofloat(min1.text);
e:=strtofloat(min2.text);
f:=d-e;
min3.text:=floattostr(f);
end;
procedure TForm1.Button3Click(Sender:
TObject);
begin
g:=strtofloat(kali1.text);
h:=strtofloat(kali2.text);
i:=g*h;
kali3.text:=floattostr(i);
end;
procedure TForm1.Button4Click(Sender:
TObject);
begin
j:=strtofloat(bagi1.text);
k:=strtofloat(bagi2.text);
l:=j/k;
bagi3.text:=floattostr(l);
end;
procedure TForm1.Button5Click(Sender:
TObject);

Petunjuk:
SELAMAT DATANG = LABEL
WARNA = BOTTON
Variabel nggak usah
procedure TForm1.Button1Click(Sender:
TObject);
begin
label1.Font.Color:=clred;
end;
procedure TForm1.Button2Click(Sender:
TObject);
begin
label1.font.color:=clblue;
end;
procedure TForm1.Button4Click(Sender:
TObject);
begin
label1.font.Color:=clyellow;
end;
procedure TForm1.Button5Click(Sender:
TObject);
begin
label1.font.Color:=clpurple;
end;
procedure TForm1.Button6Click(Sender:
TObject);
begin
label1.font.Color:=clgreen;

end;
procedure TForm1.Button7Click(Sender:
TObject);
begin
label1.font.Color:=clblack;
end;
procedure TForm1.Button8Click(Sender:
TObject);
begin
label1.font.Color:=clwhite;
end;
procedure TForm1.Button9Click(Sender:
TObject);
begin
label1.font.Color:=clred;
end;
procedure
TForm1.Button10Click(Sender:
TObject);
begin
label1.font.Color:=clblack;
end;
procedure
TForm1.Button11Click(Sender:
TObject);
begin
label1.font.Color:=clwhite;
end;
procedure TForm1.Button3Click(Sender:
TObject);
begin
close
end;
end.
MENAMPILKN BILANGAN BULAT
(KANAN GENAP, KIRI GANJIL)
INTERVAL (GROUP BOX)
PROSES (BUTTON)
KOTAK 2 (LIST BOX)
CLOSE (ADDITIONAL=>OK,
KIND=>ALL CLOSE)

VARIABELNYA INTEGER
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender:
TObject);
var
a,b,i:integer;
begin
a:=strtoint(edit1.Text);
b:=strtoint(edit2.Text);
listbox1.Clear;
listbox2.Clear;
for i:=a to b do
if i mod 2 = 0 then
ListBox1.Items.add(inttostr(i))
else ListBox2.Items.add(inttostr(i));
end;
end.
GENAP GANJIL
var
a,b,i:integer;
begin
a:=strtoint(edit1.Text);
b:=strtoint(edit2.Text);
listbox1.Clear;
for i:=a to b do
if i mod 2 = 0 then
ListBox1.Items.add(inttostr(i)+'genap')
else ListBox1.Items.add(inttostr(i)
+'ganjil');
QUIS
var
Form1: TForm1;
a,b,c:integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender:
TObject);
begin
a:=strtoint(edit1.Text);

b:=strtoint(edit2.Text);
if a>b then c:=a-b;
edit3.Text:=inttostr(c);
if a>b then
label3.Caption:='-';
if a<b then c:=a+b;
edit3.Text:=inttostr(c);
if a<b then
label3.caption:='+';
if a=b then c:=a+b;
edit3.Text:=inttostr(c);
if a=b then
label3.caption:='+';
if a>b then
label4.Caption:='hasil pengurangan';
if a<b then
label4.Caption:='hasil penjumlahan';
if a=b then
label4.Caption:='hasil penjumlahan';

end;
end.
end;
end.
KONVERSI SUHU
WIN_PAGE CONTROL_ALIGN_ALL TOP
var
Form1: TForm1;
C,R,F,K:Real;
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender:
TObject);
begin
C:=strtofloat(edt1.Text);
R:=4/5*C;
F:=(9/5*C)+32;
K:=C+273;
edt2.Text:=floattostr(R);
edt3.Text:=floattostr(F);

edt4.Text:=floattostr(K);
end;
procedure TForm1.btn3Click(Sender:
TObject);
begin
R:=strtofloat(edt5.Text);
C:=5/4*R;
F:=(9/4*R)+32;
K:=(5/4*R)+273;
edt6.Text:=floattostr(C);
edt7.Text:=floattostr(F);
edt8.Text:=floattostr(K);
end;
procedure TForm1.btn5Click(Sender:
TObject);
begin
F:=strtofloat(edt9.Text);
C:=5/9*(F-32);
R:=4/9*(F-32);
K:=(5/9*(F-32))+273;
edt10.Text:=floattostr(C);
edt11.Text:=floattostr(R);
edt12.Text:=floattostr(K);
end;
procedure TForm1.btn7Click(Sender:
TObject);
begin
K:=strtofloat(edt13.Text);
C:=K-273;
R:=4/5*(K-273);
F:=(9/5*(K-273))+32;
edt14.Text:=floattostr(C);
edt15.Text:=floattostr(R);
edt16.Text:=floattostr(F);
end;
end.
BANGUN+DIAGONAL
BENTUK_RADIOGRUP
POINT2_
var
Form1: TForm1;
implementation

{$R *.dfm}
procedure
TForm1.RadioGroup1Click(Sender:
TObject);
begin
case radiogroup1.ItemIndex of
0:begin
shape1.pen.width:=3;
shape1.Brush.Style:=bsbdiagonal;
shape1.brush.color:=clred;
shape1.Shape:=stsquare;
end;
1:begin
shape1.Brush.Style:=bsvertical;
shape1.brush.color:=clblue;
shape1.Shape:=strectangle;
end;
2:begin
shape1.Brush.Style:=bsdiagcross;
shape1.brush.color:=clyellow;
shape1.Shape:=stcircle;
end;
3:begin
shape1.Brush.Style:=bssolid;
shape1.brush.color:=clgreen;
shape1.Shape:=stellipse;
end;
end;
end;
end
MENGHADIRKAN BENTUK BESERTA
WARNA
NAMA BENTUK_BUTTON
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender:
TObject);
begin
canvas.Brush.Color:=clred;
canvas.rectangle(250,50,300,100);
end;

procedure TForm1.Button2Click(Sender:
TObject);
begin
canvas.Brush.Color:=clgreen;
canvas.rectangle(450,100,350,50);
end;
procedure TForm1.Button3Click(Sender:
TObject);
begin
canvas.Brush.Color:=clblack;
canvas.ellipse(300,150,400,250);
end;
procedure TForm1.Button4Click(Sender:
TObject);
begin
canvas.Brush.Color:=clblue;
canvas.ellipse(200,150,100,50);
end;
procedure TForm1.Button5Click(Sender:
TObject);
begin
canvas.Brush.Color:=clmaroon;
canvas.polygon([point(510,100),point(55
0,200),point(650,200),point(690,100),poi
nt(600,5)]);
end;
procedure TForm1.Button6Click(Sender:
TObject);
begin
canvas.Brush.Color:=clyellow;
canvas.polygon([point(150,350),point(20
0,300),point(250,350)]);
end;
end.
KELULUSAN
INPUT+OUTPUT_GRUPBOX
HITUNG_BUTTON
var
Form1: TForm1;
implementation
{$R *.dfm}

procedure TForm1.Button1Click(Sender:
TObject);
var a,b,c:real;
d:string;
e:string;
f:string;
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
c:=(a+b)/2;
edit3.Text:=floattostr(c);
if c>=85 then d:='A';
if (c>=80) and (c<=84) then d:='A-';
if (c>=75) and (c<=79) then d:='B+';
if (c>=70) and (c<=74) then d:='B';
if (c>=65) and (c<=69) then d:='B-';
if (c>=60) and (c<=64) then d:='C+';
if (c>=55) and (c<=59) then d:='C';
if (c>=50) and (c<=54) then d:='D';
if c<50 then d:='E';
edit4.Text:=(d);
if d='A' then e:='Sempurna';
if d='A-' then e:='Sangat Baik';
if d='B+' then e:='Sangat Baik';
if d='B' then e:='Baik';
if d='B-' then e:='Cukup';
if d='C+' then e:='Cukup';
if d='C' then e:='Kurang';
if d='D' then e:='Jelek';
if d='E' then e:='Jelek';
edit5.Text:=(e);
if (c>=55) then f:='LULUS';
if (c<=54) then f:='TIDAK LULUS';
edit6.Text:=(f);

Form1: TForm1;
ho,ht,m,Vt,Ep,Ek,E,Vmax:real;
t:integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender:
TObject);
const g=10;
Vo=0;
begin
listbox1.clear;
ho:=strtofloat(edit1.Text);
m:=strtofloat(edit2.Text);
t:=0;
listbox1.Items.Add('---------------------------------------------------------------------');
listbox1.Items.Add(' t(s) '+' ht(m) '+'
vt(m/s) '+' ep(joule) '+' ek(joule) '+'
em(joule) ');
listbox1.Items.add('---------------------------------------------------------------------');
repeat
ht:=ho-1/2*g*t*t;
vt:=g*t;
Ep:=m*g*Ht;
Ek:=1/2*m*Vt*Vt;
E:=Ep+Ek;
if ht<0 then Break;
listbox1.items.add(inttostr(t)+'
'+floattostr(ht)+'
'+floattostr(vt)+'
'+floattostr(ep)+'
'+floattostr(ek)+'
'+ floattostr(E)+'
');
t:=t+1;
until ht<=0;
Vmax:=sqrt(2*g*ho);
edit3.Text:=floattostr(Vmax);

end;
end;
end.
end.
GJB_QDHEWE
INPUT_GRUPBOX
KOTAK_LISTBOX
var

GJB_ORIN
KOTAK2_STRINGGID
INPUT_GRUPBOX

var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender:
TObject);
const g=10;
var h0,ht,m,vmax,vt,ep,ek,em:real;
t:integer;
begin
h0:=strtofloat(edit1.Text);
m:=strtofloat(edit2.Text);
t:=0;
listbox1.Clear;
listbox1.Items.Add('--------------------------------------------------------------------------------------------------------------------------'
);
listbox1.Items.Add('t ! ht ! vt !
ep
! ek
! em');
listbox1.Items.Add('--------------------------------------------------------------------------------------------------------------------------'
);
repeat
ht:=h0-1/2*g*t*t;
vt:=g*t;
ep:=m*g*ht;
ek:=1/2*m*vt*vt;
em:=ek+ep;
if ht<0 then break;
listbox1.Items.add(inttostr(t)+' !
'+floattostr(ht)+' ! '+floattostr(vt)+' !
'+floattostr(ep)+' ! '+floattostr(ek)+'
!
'+floattostr(em));
t:=t+1
until ht=0;
vmax:=sqrt(2*g*h0);
edit3.Text:=floattostr(vmax);
end;
procedure TForm1.Button2Click(Sender:
TObject);
const g=10;
var ht,h0,m,vmax,vt,ep,ek,em:real;
t:integer;
begin
h0:=strtofloat(edit4.Text);

m:=strtofloat(edit5.Text);
t:=0;
while ht>=0 do
begin
ht:=h0-1/2*g*t*t;
vt:=g*t;
ep:=m*g*ht;
ek:=1/2*m*vt*vt;
em:=ek+ep;
if ht<0 then break;
stringgrid1.cells[0,t+1]:=inttostr(t);
stringgrid1.cells[1,t+1]:=floattostr(ht);
stringgrid1.cells[2,t+1]:=floattostr(vt);
stringgrid1.cells[3,t+1]:=floattostr(ep);
stringgrid1.cells[4,t+1]:=floattostr(ek);
stringgrid1.cells[5,t+1]:=floattostr(em);
t:=t+1;
end;
vmax:=sqrt(2*g*h0);
edit6.text:=floattostr(vmax);
end;
procedure TForm1.FormCreate(Sender:
TObject);
begin
with stringgrid1 do
begin
cells[0,0]:='t';
cells[1,0]:='ht';
cells[2,0]:='vt';
cells[3,0]:='ep';
cells[4,0]:='ek';
cells[5,0]:='em';
end;
end;
end.
MENGGAMBAR GARIS
MENGGUNAKAN MTK
NAMA GARIS_BUTTON
var
Form1: TForm1;
x,y:integer;
implementation
{$R *.dfm}

procedure TForm1.Button1Click(Sender:
TObject);
var
x,y:integer;
begin
for x:=0 to clientwidth-1 do
begin
y:=clientheight div 2;
canvas.pixels [x,y]:=clred;
end
end;
procedure TForm1.Button2Click(Sender:
TObject);
var
x,y:integer;
begin
for y:=0 to clientheight-1 do
begin
x:=clientwidth div 2;
canvas.pixels [x,y]:=clblue;
end
end;
procedure TForm1.Button3Click(Sender:
TObject);
var x,y:integer;
begin
for x:=-clientwidth to clientwidth -1 do
begin
y:=x;
canvas.Pixels[x+clientwidth div
2,y+clientheight div 2]:=clgreen;
end;
end;

const a=0.005;
b=0;
c=0;
var x,y:integer;
begin
for x:=-clientwidth to clientwidth -1 do
begin
y:=trunc(a*x*x+b*x+c);
canvas.Pixels[x+clientwidth div
2,y+clientheight div 2]:=clpurple;
end;
end;
procedure TForm1.Button6Click(Sender:
TObject);
const a=0.005;
b=0;
c=0;
var x,y:integer;
begin
for x:=-clientwidth to clientwidth -1 do
begin
y:=-trunc(a*x*x+b*x+c);
canvas.Pixels[x+clientwidth div
2,y+clientheight div 2]:=clpurple;
end;
end;

procedure TForm1.Button4Click(Sender:
TObject);
var x,y:integer;
begin
for x:=-clientwidth to clientwidth -1 do
begin
y:=-x;
canvas.Pixels[x+clientwidth div
2,y+clientheight div 2]:=clgreen;
end;

procedure TForm1.Button7Click(Sender:
TObject);
const r=100;
var
x,y,y1:integer;
begin
for x:=-100 to 100 -1 do
begin
y:=trunc(sqrt(r*r-x*x));
y1:=-trunc(sqrt(r*r-x*x));
canvas.Pixels[x+(clientwidth div 2),y+
(clientheight div 2)]:=clblack;
canvas.Pixels[x+(clientwidth div 2),y1+
(clientheight div 2)]:=clblack;
end;

end;

end;

procedure TForm1.Button5Click(Sender:
TObject);

LANGKAH
Page control => klik =>taruh di form => tarik
=>property=>align=>all top=>klik kanan di
page=>new page
KALAU HASILNYA ADA KOMA PAKE
FLOAT
KALO HASILNYA TANPA KOMA2AN
EX:MOD DIV PAKE INT, jangan lupa
diasih var d,e,f integer
RUMUS
var
Form1: TForm1;
a,b,c:real;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender:
TObject);
begin
b:=strtofloat(edit1.Text);
c:=strtofloat(edit2.Text);
a:=b+c;
edit3.Text:=floattostr(a);
end;
procedure TForm1.Button2Click(Sender:
TObject);
begin
b:=strtofloat(edit4.Text);
c:=strtofloat(edit5.text);
a:=b-c;
edit6.Text:=floattostr(a);
end;
procedure TForm1.Button3Click(Sender:
TObject);
begin
b:=strtofloat(edit7.Text);
c:=strtofloat(Edit8.Text);
a:=b*c;
edit9.Text:=floattostr(a);
end;
procedure TForm1.Button4Click(Sender:
TObject);
begin
b:=strtofloat(edit10.Text);

c:=strtofloat(Edit11.Text);
a:=b/c;
edit12.Text:=floattostr(a);
end;
procedure TForm1.Button5Click(Sender:
TObject);
begin
b:=strtofloat(edit13.Text);
c:=sqrt(b);
edit14.Text:=floattostr(c);
end;
procedure TForm1.Button6Click(Sender:
TObject);
begin
b:=strtofloat(edit15.Text);
c:=strtofloat(edit16.Text);
a:=exp(c*(ln(b)));
edit17.Text:=floattostr(a);
end;
procedure TForm1.Button7Click(Sender:
TObject);
var
d,e,f:integer;
begin
e:=strtoint(edit18.Text);
f:=strtoint(edit19.Text);
d:=e mod f;
edit20.Text:=inttostr(d);
end;
procedure TForm1.Button8Click(Sender:
TObject);
var
d,e,f:integer;
begin
e:=strtoint(edit21.Text);
f:=strtoint(edit22.Text);
d:=e div f;
edit23.Text:=inttostr(d);
end;
procedure TForm1.Button9Click(Sender:
TObject);
begin
b:=strtofloat(edit24.Text);
c:=sqr (b);
edit25.Text:=floattostr(c);
end;

end.