pemrograman berorientasi proyek

17
TUGAS PEMROGRAMAN BERORIENTASI OBJECT Dosen Pengampu M.FAIRUZABADI,S.KOM.,M.KOM Oleh : SITI MUSLIKHAH 11111100092 PROGRAM STUDI TEKNIK INFORMATIKA FAKULTAS TEKNIK UNIVERSITAS PGRI YOGYAKARTA

Upload: alika-moeza

Post on 23-Oct-2015

12 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Pemrograman Berorientasi Proyek

TUGAS

PEMROGRAMAN BERORIENTASI OBJECT

Dosen Pengampu M.FAIRUZABADI,S.KOM.,M.KOM

Oleh :

SITI MUSLIKHAH

11111100092

PROGRAM STUDI TEKNIK INFORMATIKA

FAKULTAS TEKNIK

UNIVERSITAS PGRI YOGYAKARTA

2013

05 September 2013 Input Program Pertama:

Page 2: Pemrograman Berorientasi Proyek

procedure TfrmProgramPertama.btnDatakuClick(Sender: TObject);begin edtNama.Text := 'Song'; edtAlamat.Text := 'Bantul';end;

procedure TfrmProgramPertama.btnResetClick(Sender: TObject);begin edtNama.Text := ''; edtAlamat.Text := '';end;

procedure TfrmProgramPertama.btnTutupClick(Sender: TObject);begin Close;end;

end.

Output Program Pertama:

12 September 2013 Input Program Kalkulator Sederhana:procedure TForm1.Button1Click(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.Button2Click(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.Button3Click(Sender: TObject);var A,B,C : Real;begin A:= StrToFloat(Edit1.text);

Page 3: Pemrograman Berorientasi Proyek

B:= StrToFloat(Edit2.text); C:= A*B; Edit3.Text:=FloatToStr(C)end;

procedure TForm1.Button4Click(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.Button5Click(Sender: TObject);var A,B,C : Integer;begin A:= StrToInt(Edit1.text); B:= StrToInt(Edit2.text); C:= A mod B; Edit3.Text:=IntToStr(C)end;

procedure TForm1.Button6Click(Sender: TObject);begin Edit1.Text :=''; Edit2.Text :=''; Edit3.Text :='';end;

procedure TForm1.Button7Click(Sender: TObject);begin Close;end;

end.

Output Program Kalkulator Sederhana:

Page 4: Pemrograman Berorientasi Proyek

19 Oktober 2013 Input Program Tabung:procedure TForm1.Button1Click(Sender: TObject); var t,r,L,V : Real;begin //input T := StrToFloat(Edit1.Text); R := StrToFloat(Edit2.Text); //proses V := 0.25*3.14*2*r*t; L := 2*3.14*r*(r+t); //output Edit3.Text := FloatToStr(V); Edit4.Text := FloatToStr(L);end;

procedure TForm1.Button2Click(Sender: TObject);begin Edit1.Text := ''; Edit2.Text := ''; Edit3.Text := ''; Edit4.Text := '';end;

procedure TForm1.Button3Click(Sender: TObject);begin Close;end;

end.

Page 5: Pemrograman Berorientasi Proyek

Output Program Tabung:

Input Program Kerucut:procedure TForm2.Button1Click(Sender: TObject); var t,r,s,V,L : Real;begin t := StrToFloat(Edit1.Text); r := StrToFloat(Edit2.Text); s := StrToFloat(Edit3.Text);

V := 1/3*3.14*r*r*t; L := 3.14*r*(r+s);

Edit4.Text := FloatToStr(V); Edit5.Text := FloatToStr(L);end;

procedure TForm2.Button2Click(Sender: TObject);begin Edit1.Text := ''; Edit2.Text := ''; Edit3.Text := ''; Edit4.Text := ''; Edit5.Text := '';end;

procedure TForm2.Button3Click(Sender: TObject);begin Close;end;end.

Page 6: Pemrograman Berorientasi Proyek

Output Program Kerucut:

26 September 2013 Input Program IF…THEN…ELSE:procedure TForm1.Button1Click(Sender: TObject);var nilai:integer; hasil:string;begin nilai:=strtoint(edit1.Text); if nilai < 60 then hasil:= 'Tidak lulus' else hasil:='Lulus'; edit2.Text:= hasil;end;

procedure TForm1.Button2Click(Sender: TObject);begin Edit1.Text := ''; Edit2.Text := ''; Edit3.Text := ''; Edit4.Text := ''; Edit5.Text := ''; Edit6.Text := '';end;end.

Output Program IF…THEN…ELSE:

Page 7: Pemrograman Berorientasi Proyek

Input Program IF…THEN…ELSE menggunakan Gerbang Logika:procedure TForm1.Button1Click(Sender: TObject); var tb, umur, bi, ipa, mtk : integer; hasil : string;begin tb :=strtoint(edit1.Text); umur:=strtoint(edit2.Text); bi:=strtoint(edit3.Text); ipa:=strtoint(edit4.Text); mtk:=strtoint(edit5.Text); if (tb>150) AND (umur<50) AND (bi>60) AND ((ipa>70) OR (mtk>70)) then hasil := 'Diterima' else hasil := 'Tidak diterima'; Edit6.Text := hasil;

end;

procedure TForm1.Button2Click(Sender: TObject);begin Edit1.Text := ''; Edit2.Text := ''; Edit3.Text := ''; Edit4.Text := ''; Edit5.Text := ''; Edit6.Text := '';end;

procedure TForm1.Button3Click(Sender: TObject);begin Closeend;end.

Output Program IF…THEN…ELSE menggunakan Gerbang Logika:

Page 8: Pemrograman Berorientasi Proyek

03 Oktober 2013 Input Program IF…THEN…ELSE Bercabang:procedure TForm1.Button1Click(Sender: TObject);Var Kehadiran, Tugas, Kuis, UTS, UAS, Angka : real; Huruf: String;begin //ambil nilai Kehadiran, Tugas, Kuis, UTS, UAS Kehadiran:=StrToFloat(Edit1.Text); Tugas:=StrToFloat(Edit2.Text); Kuis:=StrToFloat(Edit3.Text); UTS:=StrToFloat(Edit4.Text); UAS:=StrToFloat(Edit5.Text); //Hitung nilai angka Angka:= Kehadiran*0.1+Tugas*0.2+Kuis*0.2+UTS*0.25+UAS*0.25; //Hitung nilai huruf if Angka < 20 then Huruf:='E' else if Angka < 30 then Huruf:='D' else if Angka < 35 then Huruf:='C-' else if Angka < 40 then Huruf:='C' else if Angka < 50 then Huruf:='C+' else if Angka < 60 then Huruf:='B-' else if Angka < 70 then Huruf:='B' else if Angka < 80 then Huruf:='B+' else if Angka < 90 then Huruf:='A-' else Huruf:='A'; //Tampilkan nilai angka dan huruf Edit6.Text := FloatToStr(Angka); Edit7.Text := Huruf;end;

procedure TForm1.Button2Click(Sender: TObject);begin Edit1.Text:=''; Edit2.Text:=''; Edit3.Text:=''; Edit4.Text:=''; Edit5.Text:=''; Edit6.Text:=''; Edit7.Text:='';end;

procedure TForm1.Button3Click(Sender: TObject);begin Close;end;end.

Page 9: Pemrograman Berorientasi Proyek

Output Program IF…THEN…ELSE Bercabang:

Input Program Latihan IF…THEN…ELSE Bertingkat:procedure TForm1.Button1Click(Sender: TObject);Var Kelas, Fasilitas : String; Lama : Integer; Tarif, Total : Real;begin Kelas := Edit1.Text; Lama :=StrToInt(Edit2.Text);

if Kelas ='A' then begin Tarif := 1000000; Fasilitas :='AC + Double Bed + Breakfast'; end else if Kelas ='B' then begin Tarif := 750000; Fasilitas :='AC + Single Bed + Breakfast'; end

Page 10: Pemrograman Berorientasi Proyek

else begin Tarif := 300000; Fasilitas :='AC + Single Bed'; end; Total := Lama*Tarif; Edit3.Text := FloatToStr(Tarif); Edit4.Text := Fasilitas; Edit5.Text := FloatToStr(Total);end;

procedure TForm1.Button2Click(Sender: TObject);begin Edit1.Text :=''; Edit2.Text :=''; Edit3.Text :=''; Edit4.Text :=''; Edit5.Text :='';end;

procedure TForm1.Button3Click(Sender: TObject);begin Close;end;

end.

Output Program Latihan IF…THEN…ELSE Bertingkat:

17 Oktober 2013 Input Program CASE OF:procedure TForm1.Button1Click(Sender: TObject);var kar : char; jenis : string;begin kar := Edit1.Text[1]; Case kar of 'a','i','e','o','u': jenis := 'vokal'; 'b'..'d', 'f'..'h', 'j'..'n', 'p'..'t', 'v'..'z':

Page 11: Pemrograman Berorientasi Proyek

jenis := 'konsonan'; '0'..'9': jenis := 'angka' else jenis := 'tidak terdefinisi' end; Edit2.Text := jenisend;

procedure TForm1.Button2Click(Sender: TObject);begin Edit1.Text := ''; Edit2.Text := '';end;

procedure TForm1.Button3Click(Sender: TObject);begin Close;end;end.

Output Program CASE OF:

Input Program Latihan CASE OF:procedure TForm1.Button1Click(Sender: TObject);var Kelas, LamaInap : Integer; BiayaInap, Diskon, Total : Real;begin Kelas:= StrToInt(Combobox1.Text); LamaInap := StrToInt(Edit2.Text); case Kelas of 1 : BiayaInap:= 150000; 2 : BiayaInap:= 100000; 3 : BiayaInap:= 75000; end; case Lamainap of 1..7 : Diskon:=0; 8..15: Diskon:=5; else Diskon:= 10; end; Total:=BiayaInap*LamaInap*(1-Diskon/100); Edit3.Text := FloatToStr(BiayaInap); Edit4.Text := FloatToStr(Diskon); Edit5.Text := FloatToStr(Total);end;

Page 12: Pemrograman Berorientasi Proyek

procedure TForm1.Button2Click(Sender: TObject);begin Combobox1.ItemIndex :=-1; Edit2.Text :=''; Edit3.Text :=''; Edit4.Text :=''; Edit5.Text :=''; Combobox1.Setfocus;end;

procedure TForm1.Button3Click(Sender: TObject);begin Close;end;end.

Output Program Latihan CASE OF:

JAWABAN KISI-KISI UTS 2013Input Program :procedure TForm1.Button1Click(Sender: TObject);var gol, kel : string; jA, jamL : Integer; gP, tjKel, tjA, iL, Total : Real;begin gol:= ComboBox1.Text; kel:= ComboBox2.Text; jA:= StrToInt(Edit1.Text); jamL:=StrToInt(Edit2.Text); if gol='A' then begin gP:= 2000000; iL:= jamL*50000; end else if gol='B' then begin gP:= 1500000; iL:= jamL*40000; end

Page 13: Pemrograman Berorientasi Proyek

else begin gol:='C'; gP:= 1000000; iL:= jamL*30000; end;

if (gol='A') and (kel='MENIKAH') then begin tjKel:= 300000; tjA:= 200000; end else if (gol='B') and (kel='MENIKAH') then begin tjKel:= 150000; tjA:= 100000; end else if (gol='C') and (kel='MENIKAH') then begin tjKel:= 100000; tjA:= 75000; end else begin kel:='BELUM MENIKAH'; tjKel:= 0; tjA:= 0; end;

Total := gP+tjKel+tjA+iL;

Edit3.Text := FloatToStr(gP); Edit4.Text := FloatToStr(tjKel); Edit5.Text := FloatToStr(tjA); Edit6.Text := FloatToStr(iL); Edit7.Text := FloatToStr(Total);end;

procedure TForm1.Button2Click(Sender: TObject);begin Combobox1.ItemIndex :=-1; Combobox2.ItemIndex :=-1; Edit1.Text :=''; Edit2.Text :=''; Edit3.Text :=''; Edit4.Text :=''; Edit5.Text :=''; Edit6.Text :=''; Edit7.Text :='';end;

procedure TForm1.Button3Click(Sender: TObject);begin Close;end;

end.

Page 14: Pemrograman Berorientasi Proyek

Output Program :