KEMENTRIAN AGAMA
UNIVERSITAS ISLAM NEGERI MAULANA
MALIK IBRAHIM MALANG
FAKULTAS SIANS DAN TEKNOLOGI
JURUSAN TEKNIK INFORMATIKA
Jalan Gajayana 50
Malang 65144 Telepon (0341) 551354, Faksimile (0341) 572533
Website :
http://www.uin-malang.ac.id Email : info@uin-malang.ac.id
Tugas Akhir Semester
INTERAKSI MANUSIA dan KOMPUTER
Tutorial Pembuatan Kalkulator
Nama :
Aris Diantoro
NIM :
13650105
Kelas : Teknik Informatika D
Langkah-langkahnya sebagai berikut:
1.Jalankan aplikasi Borland Delphi 7
2.Pilih File pada StatusBar, Pilih New dan pilih Aplication
Ubah ukuran pada
Height :400
Width :375
3.Ubah caption pada form 1 menjadi Kalkulator Kompleks
4.Ubah icon menjadi icon yang anda inginkan dengan catatan berformat *.ico
5. A) Masukkan 3 buah Panel, dengan ukuran berbeda sesuai gambar!
-Masukkan panel 1
Hapus identitas captionnya, lalu atur Iner dan Outernya menjadi byNone.
Gunanya untuk papan tombol.
-Masukkan panel 2, , Ubah caption nya menjadi angka ‘0’,Atur fontnya menjadi Times New, Atur ukuran Fontnya menjadi 24, Atur penataan nya menjadi taRightJustify dan terakhir atur Iner dan Outernya menjadi byLowered agar terkesan tenggelam.
-Masukkan panel 3
Atur Iner dan Outernya menjadi byRaised
B) Masukkan Button
-Masukkan 20 button dengan ukuran yang sama dengan mencopy dan paste agar konsisten.dengan ukuran
Height : 41
Width : 57
-Masukkan 1 button lagi dengan ukuran yang memajcang kebawah untuk samadengan “=”.
6. Atur
Fontnya menjadi Times New Roman
Ukuran
10, dengan style bold.
Ubah
tampilan warna
1.pada
formnya : cl3DDkShadow
2.pada
panel 3 : clGray
3.pada
panel 2 : clGray
4.pada
panel 1 : clAppWorkSpace
Kurang lebih tampilannya seperti ini
7.Sekarang
tinggal mengkoding setiap bagian di kalkulator ini:
Pada tombol 1 klik 2 kali:
begin
if
hasil.Caption='0' then
hasil.Caption:='';
if
Hasil.Caption<>' ' then
if
MemLogic='0' then
begin
MemLogic:='1';
if
MemOperator<>'' then Hasil.Caption:='1' else
Hasil.Caption:='1';
end
else
Hasil.Caption:=Hasil.Caption+'1';
end;
Pada tombol 2 klik 2 kali:
begin
if hasil.Caption='0'
then
hasil.Caption:='';
if
Hasil.Caption<>' ' then
if MemLogic='0' then
begin
MemLogic:='2';
if
MemOperator<>'' then Hasil.Caption:='2' else
Hasil.Caption:='2';
end
else
Hasil.Caption:=Hasil.Caption+'2';
end;
dan hingga pada tombol 3, 4, 5, 6, 7, 8, 9, 0.
Memasukkan kodingannya sama tinggal
merubah pada
MemLogic:=' ';
Hasil.Caption:=' '
Caption+'
Pada tombol X klik 2 kali:
begin
MemOperator:='';
if (hasil.Caption<>'')
then
if MemLogic='0' then
MemOperator:='x' else
if (MemOperator='') then
begin
MemOperator:='x';
MemLogic:='0';
MemAngka:=hasil.Caption;
end
else
begin
if MemOperator='+' then hasil.Caption:=floattostr(strtofloat(MemAngka)+strtofloat(hasil.Caption));
if MemOperator='-' then
hasil.Caption:=floattostr(strtofloat(MemAngka)-strtofloat(hasil.Caption));
if MemOperator='x' then
hasil.Caption:=floattostr(strtofloat(MemAngka)*strtofloat(hasil.Caption));
if MemOperator='/' then
hasil.Caption:=floattostr(strtofloat(MemAngka)/strtofloat(hasil.Caption));
if MemOperator='mod' then
hasil.Caption:=inttostr(strtoint(MemAngka) mod strtoint(hasil.Caption));
if MemOperator='div' then hasil.Caption:=inttostr(strtoint(MemAngka)div
strtoint(hasil.Caption));
if MemOperator='^' then
hasil.Caption:=floattostr(exp(strtofloat(hasil.Caption)*ln(strtofloat(MemAngka))));
MemAngka:=hasil.Caption;
MemOperator:='x';
MemLogic:='0';
end;
end;
Pada tombol ÷ klik 2 kali :
begin
MemOperator:='';
if (hasil.Caption<>'') then
if MemLogic='0' then
MemOperator:='/' else
if (MemOperator='') then
begin
MemOperator:='/';
MemLogic:='0';
MemAngka:=hasil.Caption;
end
else
begin
if MemOperator='+' then
hasil.Caption:=floattostr(strtofloat(MemAngka)+strtofloat(hasil.Caption));
if MemOperator='-' then
hasil.Caption:=floattostr(strtofloat(MemAngka)-strtofloat(hasil.Caption));
if MemOperator='x' then
hasil.Caption:=floattostr(strtofloat(MemAngka)*strtofloat(hasil.Caption));
if MemOperator='/' then
hasil.Caption:=floattostr(strtofloat(MemAngka)/strtofloat(hasil.Caption));
if MemOperator='mod' then
hasil.Caption:=inttostr(strtoint(MemAngka) mod strtoint(hasil.Caption));
if MemOperator='div' then hasil.Caption:=inttostr(strtoint(MemAngka)div
strtoint(hasil.Caption));
if MemOperator='^' then
hasil.Caption:=floattostr(exp(strtofloat(hasil.Caption)*ln(strtofloat(MemAngka))));
MemAngka:=hasil.Caption;
MemOperator:='/';
MemLogic:='0';
end;
end;
Pada tombol - klik 2 kali :
begin
MemOperator:='';
if (hasil.Caption<>'') then
if MemLogic='0' then
MemOperator:='-' else
if (MemOperator='') then
begin
MemOperator:='-';
MemLogic:='0';
MemAngka:=hasil.Caption;
end
else
begin
if MemOperator='+' then
hasil.Caption:=floattostr(strtofloat(MemAngka)+strtofloat(hasil.Caption));
if MemOperator='-' then
hasil.Caption:=floattostr(strtofloat(MemAngka)-strtofloat(hasil.Caption));
if MemOperator='x' then
hasil.Caption:=floattostr(strtofloat(MemAngka)*strtofloat(hasil.Caption));
if MemOperator='/' then
hasil.Caption:=floattostr(strtofloat(MemAngka)/strtofloat(hasil.Caption));
if MemOperator='mod' then
hasil.Caption:=inttostr(strtoint(MemAngka) mod strtoint(hasil.Caption));
if MemOperator='div' then hasil.Caption:=inttostr(strtoint(MemAngka)div
strtoint(hasil.Caption));
if MemOperator='^' then
hasil.Caption:=floattostr(exp(strtofloat(hasil.Caption)*ln(strtofloat(MemAngka))));
MemAngka:=hasil.Caption;
MemOperator:='-';
MemLogic:='0';
end;
end;
Pada tombol + klik 2 kali :
begin
MemOperator:='';
if (hasil.Caption<>'') then
if MemLogic='0' then
MemOperator:='+' else
if (MemOperator='') then
begin
MemOperator:='+';
MemLogic:='0';
MemAngka:=hasil.Caption;
end
else
begin
if MemOperator='+' then
hasil.Caption:=floattostr(strtofloat(MemAngka)+strtofloat(hasil.Caption));
if MemOperator='-' then
hasil.Caption:=floattostr(strtofloat(MemAngka)-strtofloat(hasil.Caption));
if MemOperator='x' then hasil.Caption:=floattostr(strtofloat(MemAngka)*strtofloat(hasil.Caption));
if MemOperator='/' then
hasil.Caption:=floattostr(strtofloat(MemAngka)/strtofloat(hasil.Caption));
if MemOperator='mod' then
hasil.Caption:=inttostr(strtoint(MemAngka) mod strtoint(hasil.Caption));
if MemOperator='div' then
hasil.Caption:=inttostr(strtoint(MemAngka)div strtoint(hasil.Caption));
if MemOperator='^' then
hasil.Caption:=floattostr(exp(strtofloat(hasil.Caption)*ln(strtofloat(MemAngka))));
MemAngka:=hasil.Caption;
MemOperator:='+';
MemLogic:='0';
end;
end;
Pada tombol OFF klik 2 kali :
begin
close;
end;
end.
Pada tombol C klik 2 kali :
begin
hasil.Caption:='0';
MemLogic:='';
MemAngka:='';
MemOperator:='';
end;
procedure TForm1.Button18Click(Sender: TObject);
begin
if hasil.Caption<>'' then
hasil.Caption:=hasil.Caption
+ ',';
end;
Pada tombol = klik 2 kali :
begin
if MemOperator='+' then
hasil.Caption:=floattostr(strtofloat(MemAngka)+strtofloat(hasil.Caption));
if MemOperator='-' then
hasil.Caption:=floattostr(strtofloat(MemAngka)-strtofloat(hasil.Caption));
if MemOperator='x' then
hasil.Caption:=floattostr(strtofloat(MemAngka)*strtofloat(hasil.Caption));
if MemOperator='/' then
hasil.Caption:=floattostr(strtofloat(MemAngka)/strtofloat(hasil.Caption));
MemAngka:=hasil.Caption;
MemLogic:='0';
end;
Pada tombol % klik 2 kali :
var angka:real;
begin
angka:=StrToFloat(hasil.Caption);
angka:=angka/100;
hasil.Caption:=FloatToStr(angka);
end;
Pada tombol sin klik 2 kali :
var sudut : real;
begin
if Hasil.Caption<>' ' then
begin
sudut:=strtofloat(Hasil.Caption);
sudut:=sudut*pi/180;
Hasil.Caption :=
floattostr(sin(sudut));
end;
end;
Pada tombol cos klik 2 kali :
var sudut:real;
begin
if hasil.Caption<>'' then
begin
sudut:=strtofloat(hasil.Caption);
sudut:=sudut*pi/180;
hasil.Caption := floattostr(cos(sudut));
MemLogic :='0';
end;
end;
Pada tombol tan klik 2 kali :
var sudut,a,b:real;
begin
if hasil.Caption<>'' then
begin
sudut:=strtofloat(hasil.Caption);
sudut:=sudut*pi/180;
a:=sin(sudut);
b:=cos(sudut);
sudut:=a/b;
hasil.Caption := floattostr((sudut));
MemLogic :='0';
end;
end;
8.Dan terakhir
jalankan dengan F9.
9.Hasil Akhir
0 komentar:
Posting Komentar