Lampiran Listing Program Tugas Praktikum Modul I  Kode Program Tugas Praktikum No 1. procedure TForm1.Button1Click(Sender: TObject); begin close; end; procedure TForm1.FormCreate(Sender: TObject); begin Label2.Caption:='Sedang Belajar Bahasa Pemrograman II'; Label3.Caption:='Menggunkan Borland Delphi';

end;  Kode Program Tugas Praktikum No 2. procedure TForm1.Button1Click(Sender: TObject); begin Edit1.Text:='Sesungguhnya Dibalik Kesulitan Itu Terdapat Kemudahan'; end; procedure TForm1.Button2Click(Sender: TObject); begin Close; end;

 Kode Program Tugas Praktikum No 3. procedure TForm1.Button2Click(Sender: TObject); begin Close; end; procedure TForm1.Button1Click(Sender: TObject); begin Edit5.Text:=Edit1.Text; Edit6.Text:=Edit2.Text; Edit7.Text:=Edit3.Text; Edit8.Text:=Edit4.Text; end;

Modul Teori dan Praktikum Bahasa Pemrograman Delphi 43

Lampiran Listing Program Tugas Praktikum Modul II  Kode Program Tugas Praktikum No 1a. procedure TForm1.Button1Click(Sender: TObject); var a,b,c :integer; begin a:=StrToInt(Edit1.Text); b:=StrToInt(Edit2.Text); c:=a+b; Edit3.Text:=IntToStr(c); end; procedure TForm1.Button2Click(Sender: TObject); var a,b,c :integer; begin a:=StrToInt(Edit1.Text); b:=StrToInt(Edit2.Text); c:=a-b; Edit3.Text:=IntToStr(c); end; procedure TForm1.Button3Click(Sender: TObject); var a,b,c :real; begin a:=StrToFloat(Edit1.Text); b:=StrToFloat(Edit2.Text); c:=a/b; Edit3.Text:=FloatToStr(c); end; procedure TForm1.Button4Click(Sender: TObject); var a,b,c :integer; begin a:=StrToInt(Edit1.Text); b:=StrToInt(Edit2.Text); c:=a*b; Edit3.Text:=IntToStr(c); end; procedure TForm1.Button5Click(Sender: TObject); var a,b :real; begin a:=StrToFloat(Edit1.Text); b:=StrToFloat(Edit2.Text); Edit3.Text:=FloatToStr(exp(b*ln(a))); end; procedure TForm1.BitBtn2Click(Sender: TObject); begin Close; end; procedure TForm1.BitBtn1Click(Sender: TObject); begin Edit1.Clear; Edit2.Clear; Edit3.Clear; Edit1.SetFocus; end;

 Kode Program Tugas Praktikum No 1b. procedure TForm1.Button1Click(Sender: TObject); var a,b : Real; begin Memo1.Clear; a:=StrToFloat(Edit1.Text); b:=StrToFloat(Edit2.Text); Memo1.Lines.Add('Penjumlahan = '+FloatToStr(a+b)); Memo1.Lines.Add('Pengurangan = '+FloatToStr(a-b)); Memo1.Lines.Add('Perkalian = '+FloatToStr(a*b)); Memo1.Lines.Add('Pembagian = '+FloatToStr(a/b)); Memo1.Lines.Add('Perpangkatan = '+FloatToStr(exp(b*ln(a)))); end;

Modul Teori dan Praktikum Bahasa Pemrograman Delphi 44

procedure TForm1.Button2Click(Sender: TObject); begin Edit1.Text:=''; Edit2.Clear; Memo1.Clear; end; procedure TForm1.BitBtn1Click(Sender: TObject); begin Application.Terminate; end;

 Kode Program Tugas Praktikum No 2. procedure TForm1.Button1Click(Sender: TObject); begin Edit4.Text:='Rp. '+(IntToStr(StrToInt(Edit2.Text)*StrToInt(Edit3.Text)))+',00'; end; procedure TForm1.BitBtn1Click(Sender: TObject); begin Application.Terminate; end;

 Kode Program Tugas Praktikum No 3. procedure TForm1.Button1Click(Sender: TObject); begin Edit4.Text:=IntToStr(StrToInt(Edit3.Text)-StrToInt(Edit2.Text))+'Tahun'; end; procedure TForm1.Button2Click(Sender: TObject); begin Edit1.Clear; Edit2.Clear; Edit3.Clear; Edit4.Clear; Button1.SetFocus; end; procedure TForm1.BitBtn1Click(Sender: TObject); begin Application.Terminate; end;

 Kode Program Tugas Praktikum No 4. procedure TForm1.Button1Click(Sender: TObject); var cel, fah : real; begin cel := StrToFloat(Edit1.Text); Fah := 1.8 * cel +32; Edit2.Text:= FloatToStr(fah); end; procedure TForm1.BitBtn1Click(Sender: TObject); begin Edit1.Clear; Edit2.Clear; Edit1.SetFocus; end; procedure TForm1.BitBtn2Click(Sender: TObject); begin Close; end;

Modul Teori dan Praktikum Bahasa Pemrograman Delphi 45

Lampiran Listing Program Tugas Praktikum Modul III  Kode Program Tugas Praktikum No 1 procedure TForm1.BitBtn1Click(Sender: TObject); begin if EdtPas.Text='amik' then Form2.show else begin MessageDlg('Password Anda Salah'+chr(10)+chr(13)+'Coba Anda Ulang!', mtInformation,[mbOK],0); EdtPas.SetFocus; end; end;

 Kode Program Tugas Praktikum No 2 procedure TForm1.BitBtn3Click(Sender: TObject); begin Edit1.Clear; Edit2.Clear; Edit3.Clear; Memo1.Clear; Edit1.SetFocus; end; procedure TForm1.BitBtn2Click(Sender: TObject); begin Application.Terminate; end; procedure TForm1.Button1Click(Sender: TObject); Var A,B,C,D,X1,X2,Z1,Z2 : Real; begin A:=StrToFloat(Edit1.Text); B:=StrToFloat(Edit2.Text); C:=StrToFloat(Edit3.Text); D:=B*B-4*A*C; if D=0 then begin X1:= -B/(2*A); Memo1.Lines.Add('Ada 2 akar kembar, yaitu: '); Memo1.Lines.Add('X1 = X2 = '+FloatToStr(X1)); end else begin if D > 0 then begin X1:= (-B + Sqrt(D))/(2*A); X2:= (-B - Sqrt(D))/(2*A); Memo1.Lines.Add('Ada 2 akar real berlainan, yaitu: '); Memo1.Lines.Add('X1 = '+FloatToStr(X1)); Memo1.Lines.Add('X2 = '+FloatToStr(X2)); end else begin Z1:= -B /(2*A); Z2:= Sqrt(-D)/(2*A); Memo1.Lines.Add('Ada 2 akar imaginair berlainan, yaitu: '); Memo1.Lines.Add('X1 = '+FloatToStr(Z1)+' + '+FloatToStr(Z2)+'i'); Memo1.Lines.Add('X2 = '+FloatToStr(Z1)+' - '+FloatToStr(Z2)+'i'); end; end; end;

 Kode Program Tugas Praktikum No 3a. procedure TForm1.FormCreate(Sender: TObject); begin ComboBoxGol.Items.Add('I'); ComboBoxGol.Items.Add('II'); ComboBoxGol.Items.Add('III'); ComboBoxGol.Items.Add('IV'); end;

Modul Teori dan Praktikum Bahasa Pemrograman Delphi 46

procedure TForm1.BitBtnSelesaiClick(Sender: TObject); begin close; end; procedure TForm1.BitBtnUlangClick(Sender: TObject); begin EdtNIP.Text:=''; EdtNama.Text:=''; EdtBagian.Text:=''; ComboBoxGol.Text:=''; EdtGapok.Text:=''; EdtTunjKel.Text:=''; EdtTotal.Text:=''; EdtPegawai.Text:=''; EdtGolongan.Text:=''; EdtJenisKel.Text:=''; CheckBoxPria.Checked:=false; CheckBoxWanita.Checked:=False; EdtNIP.SetFocus; end; procedure TForm1.BitBtnProsesClick(Sender: TObject); begin If ComboBoxGol.Text='I' Then begin If CheckBoxPria.Checked Then begin EdtPegawai.Text:=EdtNama.Text; EdtGolongan.Text:=ComboBoxGol.Text; EdtJenisKel.Text:=CheckBoxPria.Caption; EdtGapok.Text:='1500000'; EdtTunjKel.Text:=FloatToStr(0.35*StrToInt(EdtGapok.Text)); EdtTotal.Text:=FloatToStr(StrToInt(EdtGapok.Text)+ StrToInt(EdtTunjKel.Text)); end Else If CheckBoxWanita.Checked then begin EdtPegawai.Text:=EdtNama.Text; EdtGolongan.Text:=ComboBoxGol.Text; EdtJenisKel.Text:=CheckBoxWanita.Caption; EdtGapok.Text:='1500000'; EdtTunjKel.Text:=FloatToStr(0.2*StrToInt(EdtGapok.Text)); EdtTotal.Text:=FloatToStr(StrToInt(EdtGapok.Text)+ StrToInt(EdtTunjKel.Text)); end; end Else If ComboBoxGol.Text='II' Then begin If CheckBoxPria.Checked Then begin EdtPegawai.Text:=EdtNama.Text; EdtGolongan.Text:=ComboBoxGol.Text; EdtJenisKel.Text:=CheckBoxPria.Caption; EdtGapok.Text:='1000000'; EdtTunjKel.Text:=FloatToStr(0.30*StrToInt(EdtGapok.Text)); EdtTotal.Text:=FloatToStr(StrToInt(EdtGapok.Text)+ StrToInt(EdtTunjKel.Text)); End Else If CheckBoxWanita.Checked then begin EdtPegawai.Text:=EdtNama.Text; EdtGolongan.Text:=ComboBoxGol.Text; EdtJenisKel.Text:=CheckBoxWanita.Caption; EdtGapok.Text:='1000000'; EdtTunjKel.Text:=FloatToStr(0.25*StrToInt(EdtGapok.Text)); EdtTotal.Text:=FloatToStr(StrToInt(EdtGapok.Text)+ StrToInt(EdtTunjKel.Text)); end; end Else If ComboBoxGol.Text='III' Then

Modul Teori dan Praktikum Bahasa Pemrograman Delphi 47

begin If CheckBoxPria.Checked Then begin EdtPegawai.Text:=EdtNama.Text; EdtGolongan.Text:=ComboBoxGol.Text; EdtJenisKel.Text:=CheckBoxPria.Caption; EdtGapok.Text:='7500000'; EdtTunjKel.Text:=FloatToStr(0.25*StrToInt(EdtGapok.Text)); EdtTotal.Text:=FloatToStr(StrToInt(EdtGapok.Text)+ StrToInt(EdtTunjKel.Text)); end Else If CheckBoxWanita.Checked then begin EdtPegawai.Text:=EdtNama.Text; EdtGolongan.Text:=ComboBoxGol.Text; EdtJenisKel.Text:=CheckBoxWanita.Caption; EdtGapok.Text:='7500000'; EdtTunjKel.Text:=FloatToStr(0.20*StrToInt(EdtGapok.Text)); EdtTotal.Text:=FloatToStr(StrToInt(EdtGapok.Text)+ StrToInt(EdtTunjKel.Text)); end; end Else If ComboBoxGol.Text='IV' Then begin If CheckBoxPria.Checked Then begin EdtPegawai.Text:=EdtNama.Text; EdtGolongan.Text:=ComboBoxGol.Text; EdtJenisKel.Text:=CheckBoxPria.Caption; EdtGapok.Text:='500000'; EdtTunjKel.Text:=FloatToStr(0.20*StrToInt(EdtGapok.Text)); EdtTotal.Text:=FloatToStr(StrToInt(EdtGapok.Text)+ StrToInt(EdtTunjKel.Text)); end Else If CheckBoxWanita.Checked then begin EdtPegawai.Text:=EdtNama.Text; EdtGolongan.Text:=ComboBoxGol.Text; EdtJenisKel.Text:=CheckBoxWanita.Caption; EdtGapok.Text:='500000'; EdtTunjKel.Text:=FloatToStr(0.15*StrToInt(EdtGapok.Text)); EdtTotal.Text:=FloatToStr(StrToInt(EdtGapok.Text)+ StrToInt(EdtTunjKel.Text)); end; end end;

 Kode Program Tugas Praktikum No 3b. procedure TForm1.FormCreate(Sender: TObject); begin ComboBoxGol.Items.Add('1'); ComboBoxGol.Items.Add('2'); ComboBoxGol.Items.Add('3'); ComboBoxGol.Items.Add('4'); end; procedure TForm1.BtnSelesaiClick(Sender: TObject); begin close; end; procedure TForm1.BtnUlangClick(Sender: TObject); begin EdtNIP.Text:=''; EdtNama.Text:=''; EdtBagian.Text:=''; ComboBoxGol.Text:=''; EdtGapok.Text:=''; EdtTunjKel.Text:=''; EdtTotal.Text:=''; EdtNIP.SetFocus; end;

Modul Teori dan Praktikum Bahasa Pemrograman Delphi 48

procedure TForm1.BtnProsesClick(Sender: TObject); var Gol : Integer; begin Gol := StrToInt(ComboBoxGol.Text); Case Gol Of 1 : EdtGapok.Text:='1500000'; 2 : EdtGapok.Text:='1000000'; 3 : EdtGapok.Text:='750000'; 4 : EdtGapok.Text:='500000'; End; If RadPria.Checked Then EdtTunjKel.Text:=FloatToStr(0.35*StrToInt(EdtGapok.Text)) Else EdtTunjKel.Text:='0'; EdtTotal.Text:=FloatToStr(StrToInt(EdtGapok.Text)+ StrToInt(EdtTunjKel.Text)); end;

Modul Teori dan Praktikum Bahasa Pemrograman Delphi 49