ah jar Kuli ter A i r e t a u Buku M raman Komp g Pemro – 9 1 Modul
Bertho Tantular, M.Si.
PEMROGRAMAN KOMPUTER
KATA PENGANTAR
Bismillahirrahmanirrahiim.
Segala puji dan syukur penulis panjatkan kepada Allah SWT atas segala nikmat dan kuasa-Nya akhirnya modul Pemrograman Komputer dapat diselesaikan. Modul ini merupakan salah satu acuan bagi mahasisa !urusan Statistika yang sedang mengikuti praktikum mata kuliah pemrograman komputer. Modul ini merupakan penjelasan singkat penggunaan so"tare #a$arus untuk statistika dengan disertai contoh-contoh. Modul ini terdiri atas sembilan bagian yaitu %ahasa Pemrograman& 'bjek Pascal dalam #a$arus& Struktur Kondisi& Pengulangan& (ariabel %erindeks& Prosedur dan )ungsi& Membuat *ra"ik& 'bject 'riented Programming.
Modul ini penulis harapkan dapat membantu mahasisa dalam melaksanakan Praktikum mata kuliah pemrograma komputer. Penulis menyadari masih banyak kekurangan pada modul ini. +ntuk itu penulis mengharapkan adanya kritik dan saran guna menyempurnakan modul ini agar nantinya dapat menjadi man"aat bagi pembacanya&
Akhir kata penulis ucapkan terima kasih banyak kepada semua pihak yang telah membantu penulisan modul praktikum ini.
Penulis&
%ertho Tantular& M.Si.
Modul Pemrograman Komputer
DAFTAR ISI
KATA PENGANTAR DAFTAR ISI............................................................................................................1 DESKRIPSI MATA KULIAH.................................................................................5 MODUL 1 BAHASA PEMROGRAMAN..............................................................6 Bagian 1 BAHASA PEMROGRAMAN PASCAL..................................................6 A. Pengertian Baa!a Pe"r#gra"an................................................................... 6 B. Baa!a Pa!$a% &an Per'e"(angann)a............................................................* C. Fit+r O(,e$t Pa!$a%..........................................................................................D. A%g#rit"a &an F%# Cart............................................................................1/ E. S#a%0!#a%........................................................................................................11 Bagian BAHASA PEMROGRAMAN LA2ARUS............................................ 13 A. Pengena%an S#4tare Laar+!.......................................................................13 B. In!ta%a!i Pr#gra" Laar+!.............................................................................1 C. Me"(+at Se(+a F#r".................................................................................1* D. Mengganti Na"a F#r" &an Mena"(a'an 7+&+%.......................................18 E. Mene"9at'an K#"9#nen 9a&a F#r"...........................................................1 F. Mengat+r Tata%eta' K#"9#nen..................................................................... G. Meng+(a Ni%ai Pr#9erti..............................................................................3 H. Me"(+at Met#&:Pr#$e&+re %eat E;ent....................................................5 I. K#"9i%a!i &an 7a%an'an Pr#gra"..................................................................7. Ur+tan Perinta..............................................................................................3/ K. Men+ &an Perinta 9a&a Laar+!..................................................................31 L. C#"9#nent< Pr#9ert)< Met#&< E;ent...........................................................33 M. Cara Laar+! Be'er,a...................................................................................35 N. Be(era9a O(,e' &an Met#&........................................................................36 O. S#a%0!#a%.......................................................................................................3*
MODUL OB7EK PASCAL DALAM LA2ARUS..............................................38 Bagian 1 =ARIABEL DAN KONSTANTA ..........................................................3 A. =aria(e%.........................................................................................................3-
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1
Modul Pemrograman Komputer B. K#n;er!i Ti9e Data.......................................................................................3C. Integer...........................................................................................................1 D. Rea%...............................................................................................................3 E. String.............................................................................................................6 F. K#"entar Pr#gra" ......................................................................................G. K#n!tanta ...................................................................................................51 H. S#a%0!#a%.......................................................................................................5 Bagian OPERASI MATEMATIKA....................................................................5 A. O9erat#r Da!ar Mate"ati'a..........................................................................5 B. F+ng!i S>R &an S>RT.................................................................................55 C. F+ng!i E?P &an LN......................................................................................5* D. F+ng!i Trig#n#"etri.....................................................................................5E. O9erat#r MOD &an DI=...............................................................................61 F. F+ng!iI TRUNC &an FRAC..........................................................................63 G. F+ng!i ROUND............................................................................................65 H. Pena"(aan &an Peng+rangan &engan !at+.................................................6* I. S#a%0!#a%.........................................................................................................68 Bagian 3 OPERASI KARAKTER DAN STRING................................................*/ A. F+ng!i ORD &an CHR..................................................................................*/ B. F+ng!i UPCASE...........................................................................................* C. F+ng!i LENGTH..........................................................................................*3 D. F+ng!i COP@................................................................................................*3 E< F+ng!i POS...................................................................................................* F. F+ng!i CONCAT...........................................................................................* G. Pr#!e&+r FORMAT.......................................................................................* H. S#a%0!#a%.......................................................................................................*6
MODUL 3 STRUKTUR KONDISI.......................................................................** Bagian 1 KONDISI IF..THEN ..............................................................................*8 A. Pengertian K#n&i!i.......................................................................................*8 B. Str+'t+r I4...Ten &an I4...Ten....E%!e.........................................................*8 C. K#i&i!i Le(i &ari Sat+.................................................................................81 D. Str+'t+r IF Berting'at..................................................................................86 E. B%#' State"ent..............................................................................................8* Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 2
Modul Pemrograman Komputer Bagian KONDISI CASE..OF..............................................................................-1 A. Str+'t+r Ca!e...O4.........................................................................................-1 B. Ca!e...O4 &engan Be(era9a K#n!tanta &an Rentang K#n!tanta...................-3 C. Str+'t+r Ca"9+ran........................................................................................-6 D. S#a%0!#a%.......................................................................................................-6
MODUL PENGULANGAN...............................................................................-Bagian 1 PENGULANGAN FOR..DO................................................................1// A. Peng+%angan FOR .. DO.............................................................................1// Bagian PENGULANGAN DENGAN KONDISI.............................................1/5 A. Str+'t+r i%e D#................................................................................1/5 B. Str+'t+r Re9eat .. Unti%..............................................................................1/8 C. S#a%0!#a% .....................................................................................................11
MODUL 5............................................................................................................113 =ARIABEL BERINDEKS...................................................................................113 Bagian 1 ARRA@.................................................................................................11 A. Arra)...........................................................................................................11 B. Arra) M+%ti&i"en!i.....................................................................................116 C. Arra) Dina"i!.............................................................................................118 D. S#a%0!#a%.....................................................................................................13 Bagian TIPE< SET DAN RECORD.................................................................. 15 A. Ti9e.............................................................................................................15 B. Set...............................................................................................................1* C. Re$#r&.........................................................................................................1* D. S#a%0!#a%.....................................................................................................131
MODUL 6 PROSEDUR DAN FUNGSI............................................................. 13 Bagian 1 PROSEDUR..........................................................................................133 A. Pr#$e&+re....................................................................................................133 B. S#a%0!#a%......................................................................................................136 Bagian FUNGSI................................................................................................13* A. F+ng!i........................................................................................................13* B. F+ng!i04+ng!i Stati!ti'a..............................................................................1/ Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 3
Modul Pemrograman Komputer C. F+ng!i Integra%............................................................................................13 D. S#a%0!#a%.....................................................................................................16
MODUL * MEMBUAT DIAGRAM...................................................................18 Bagian 1 DIAGRAM BATANG.......................................................................... 1A. BarCart......................................................................................................1B. S#a%0!#a%......................................................................................................151 Bagian FUNGSI CHART..................................................................................15 A. Cart........................................................................................................... 15 B. S#a%0!#a%......................................................................................................158
MODUL 8 MENGAKSES BERKAS DAN PESAN KESALAHAN.................15Bagian 1 MENGAKSES BERKAS.....................................................................16/ A. Menga'!e! Ber'a!......................................................................................16/ Bagian MENEMUKAN PESAN KESALAHAN...............................................16 A. Pe!an Ke!a%aan........................................................................................165 B. S#a%0!#a%......................................................................................................1*
MODUL - OB7ECT ORIENTED PROGRAMMING........................................1* Bagian 1 MEMBUAT UNIT................................................................................1*5 A. O(,e' &an Ke%a! .........................................................................................1*5 B. Mena"(a Met#&e.....................................................................................1*6 C. De!tr+'t#r...................................................................................................1*D. =i!i(i%ita!.................................................................................................... 1*E. Peari!an....................................................................................................181 F. S#a%0!#a%......................................................................................................181 Bagian MEMBUAT SOFTARE STATISTIKA.............................................18 A. Me"(+at Ke%a!...........................................................................................18 B. Me"(+at Men+ 9a&a F#r".........................................................................185 C. Men&e!ain F#r".........................................................................................18* D. F#r" Stati!ti'a De!'ri9ti4..........................................................................1- E. S#a%0!#a%......................................................................................................1-3 DAFTAR PUSTAKA...........................................................................................1-*
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 4
Modul Pemrograman Komputer
DESKRIPSI MATA KULIAH
Mata '+%ia Pe"r#gra"an '#"9+ter a&a%a "ata '+%ia )ang "e"(eri'an 9en,e%a!an !ing'at "engenai (aa!a 9e"r#gra"an Pa!$a% &an 9engg+naan !#4tare Laar+! +nt+' !tati!ti'a &engan &i!ertai $#nt#0$#nt#. T+,+an "ata '+%ia ini agar "aa!i!a "e"aa"i a%g#rit"a0a%g#rit"a &a%a" Baa!a Pe"r#gra"an Pa!$a%<
'#n&i!i< 9eng+%angan< arra)< 9r#!e& +r &an 4+ng! i< &an
O(,e$t Oriente& Pr#gra""ing !eingga "a"9+ "e"(+at !+at+ !#4tare !tati!ti'a "engg+na'an (aa!a 9e"r#gra"an ;i!+a% Laar+!.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 5
Modul Pemrograman Komputer
MODUL 1 BAHASA PEMROGRAMAN
PENDAHULUAN
Da%a" "#&+% ini a'an &i9e%a,ari "engenai 9engertian (aa!a 9e"r#gra"an< ,eni!0,eni! (aa!a 9e"r#gra"an< !e,ara (aa!a Pa!$a% &an 9er'e"(angann)a ingga 'e (aa!a 9e"r#gra"an ;i!+a%. M#&+% ini ter&iri ata! &+a (agian )ait+ "engenai (aa!a 9e"r#gra"an #gra"an Pa!$a% &an Pengena%an Baa!a Pe"r#gra"an Laar+!. Da%a" (agian 9erta"a a'an &i,e%a!'an "engenai 9engertian (aa!a 9e"r#gra"an< ,eni!0,eni! (aa!a 9e"r#gra"an< !e,ara (aa!a 9e"r#gra"an Pa!$a%< 4it+r04it+r #(,e' Pa!$a% !erta a%g#irt"a &an &iagra" a%ir F%# Cart. Pa&a (agian 'e&+a a'an &i,e%a!'an "engenai 9engena%an !#4tare Laar+!< in!ta%%a!i !#4tare Laar+!< 9engena%an %ing'+ngan 'er,a Laar+!< "e"(+at &an "engat+r area 'er,a F#r"< "engat+r 9r#9ertie! #(,e' &a%a" 4#r"< 9engena%an i!ti%a0i!ti%a &a%a" !#4tare Laar+! !e9erti event, method, properties.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal
Modul Pemrograman Komputer
Bagian 1 BAHASA PEMROGRAMAN PASCAL
A. Pengertian Bahasa Pemrograman
Pr#gra" '#"9+ter a&a%a !+at+ i"9+nan &ari 9erinta )ang "e"(erita+'an 'e9a&a '#"9+ter a9a )ang ar+ ! &i%a'+'an. Agar 9erinta ter!e( +t &a9at &i"engerti #%e '#"9+ter< 9erinta ter!e(+t 9er%+ &it+%i! &a%a" (aa!a )ang &i"engerti '#"9+ter )ang &i!e(+t Baa!a Pe"r#gra"an. F+ng!i +ta"a &ari (aa!a 9e"r#gra"an a&a%a "eng+(a 9erinta09erinta &a%a" (aa!a "an+!ia "en,a&i (aa!a )ang &i"engerti #%e "e!in< ata+ %e(i !ing'atn)a &i!e(+t (aa!a "e!in !eingga 9erinta ter!e(+t &a9at &i%a'!ana'an #%e '#"9+ter. Se$ara +"+" (aa!a 9e"r#gra"an &i(agi "en,a&i tiga (agian )ait+ 1. Baa!a Ting'at Ren&a )ait+ (aa!a 9e"r#gra"an )ang 9a%ing &e'at &engan (aa!a "e!in< (ia!an)a an)a (er"ain &engan ang'a / &an 1 !a,a. C#nt#n)a Assembly< Turbo Assembler. . Baa!a Ting'at Menenga )ait+
(aa!a
9e"r#gra"an
)ang
"engg+na'an
9erinta09erinta
!e&erana &engan !at+ 'ata !a,a. Ke+ngg+%ann)a a&a%a 'e$e9atan 9r#!e! +nt+' (aa!a ini $+'+9 (ai'. C#nt#n)a C, C++, Visual C++ 3. Baa!a Ting'at Tinggi )ait+ (aa!a 9e"r#gra"an )ang 9a%ing &e'at &engan (aa!a "an+!ia< &engan 'ata %ain "engg+na'an 9erinta09erinta &a%a" (aa!a "an+!ia '+!+!n)a Baa!a Inggri!. Ke'+rangann)a a&a%a 'e$e9atan 9r#!e!n)a '+rang (ai'. C#nt#n)a Pascal, Basic, COBOL, Fortran, Basic, elphi. Unt+' "e"+&a'an &a%a" 9e"(+atan 9r#gra" te%a !e,a' %a"a &iran$ang !+at+ 9e"r#gra"an
)ang
ter!tr+'t+r. Arti
'ata
ter!tr+'t+r
a&a%a
!+at+
$ara
9e"r#gra"an )ang an)a "e"9+n)ai !at+ "a!+'an a%+r 9r#gra"< &an
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal !
Modul Pemrograman Komputer "engin&ari 9engg+naan %e(i &ari !at+ "a!+'an. Sa%a !at+ 9r#gra" )ang te%a %a"a &iran$ang +nt+' 9e"r#gra"an ter!tr+'t+r a&a%a Pascal.
B. Bahasa Pascal dan Perkembangannya
Baa!a PASCAL 9erta"a 'a%i &i'e"(ang'an 9a&a aa% ta+n */0an #%e NICLAUS IRTH &i Te$ni$a% Uni;er!it)< 2+ri$ Si!!. Na"a PASCAL &ia"(i% &ari na"a !e#rang a%i "ate"ati'a (ang!a Peran$i!< )ait+ BLEISE PASCAL )ang te%a (er,a!a "ene"+'an a%at it+ng "e'ani! 9erta"a &i&+nia 9a&a a(a& 'e01*. Pa&a Aa%n)a (aa!a 9e"r#gra"an ini &i9er'ena%'an &engan t+,+an +nt+' "en,e%a!'an "a!a%a 9e"r#gra"an '#"9+ter (agi "aa!i!a )ang (e%a,ar 9e"r#gra"an '#"9+ter. Tern)ata &a%a" a't+ !ing'at< naa!a 9e"r#gra"an ini "en,a&i !a%a !at+ (aa!a )ang !angat 9#9+%er &i'a%angan +ni;er!ita!< !eingga "en,a&i ,+%+'an !e(agai (aa!a +ni;er!ita!. M+%ai &ari aa% 9er'e"(angann)a ingga !aat ini (an)a' !e'a%i ,eni! (aa!a 9e"r#gra"an ini< "a!ing0"a!ing "er+9a'an a!i% 9enge"(angann)a< antara %ain UCSD Pa!$a% Mi$r#!#4t Pa!$a% A99%e Pa!$a% T+r(# Pa!$a% Diantara ;er!i0;er!i )ang a&a< T+r(# Pa!$a% "er+9a'an ;er!i )ang !angat 9#9+%er !aat ini. Baa!a 9e"r#gra"an ini ter"a!+' 'ateg#ri Hig Le;e% Lang+age. In!tr+'!i0in!tr+'!i )ang &ig+na'an &a%a" (aa!a 9e"r#gra"an ini !angat !i!te"ati! &an ter!tr+'t+r. Baa!a Pa!$a% "er+9a'an (aa!a 9e"r#gra"an 9erta"a )ang "en&+'+ng #(,e$t #riente& 9r#gra""ing Ob!ect Oriented Pro"rammin" )ang 9erta"a. M+%an)a Baa!a Pa!$a% &i'e"(a ng'an #%e Apple Computer Company 9a&a ta+n 1-83 teta9i 'e"+&ian Borland "enge"(ang'ann)a &engan na"a T+r(# Pa!$a%. T+r(# Pa!$a% "er+9a'an (aa!a 9e"r#gra"an (er(a!i! 9a&a command line inter#ace. T+r(# Pa!$a% "er+9a'an (aa!a )ang $a!e in!en!iti;e )ang (erarti 9en+%i!an &a%a" +r+4 'a9ita% "a+9+n +r+4 'e$i% ti&a' &i9er"a!a%a'an.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal "
Modul Pemrograman Komputer O(,e' Pa!$a% !e$ara +"+" &a9at &i'ata'an !e(agai (aa!a 9e"r#gra"a n )(ri& &a%a" arti (aa!a Pa!$a% "en&+'+ng 9a&a Pe"r#gra"an (er!tr+'t+r &an (er#rienta!i #(,e'. $tructured and Ob!ect Oriented Pro"rammin" . Baa!a Pa!$a% ini &a9at &ig+na'an +nt+' (er(agai a9%i'a!i !e9erti a9%i'a!i 9enga,aran< 9enge"(angan ga"e< a9%i'a!i (i!ni!< a9%i'a!i internet< a9%i'a!i '#"+ni'a!i< a%at0a%at 9enge"(angan &an 'erne% !i!te" #9era!i. Seiring &engan 9er'e"(angan te'n#%#gi ter'ait &engan !i!te" #9era!i )ang &ig+na'an B#r%an& "enge"(ang'an (aa!a 9e"r#gra"an Pa!$a% agar &a9at &ia&a9ta!i #%e !i!te" #9era!i )ang (ar+. Per'e"(angan !i!te" #9era!i ;i!+a% !e9erti in!< Ma$ OS &an Lin+ a'irn)a B#r%an& "e"+t+!'an +nt+' "e"(+at 9enge"(angan Baa!a Pa!$a% "en,a&i Baa!a 9e"r#gra" an ;i!+a% &engan na"a
Delphi.
Da%a"
9er'e"(angannn)a
De%9i
"en,a&i A%at
9enge"(angan a9%i'a!i ter(ai' %apid Application evelopment !aat it+. =er!i 9erta"a De%9i &i ri%i! 9a&a ta+n 1--5 )ang 'a)a a'an 9a'et09a'et &an !e,+"%a !et '#"9#nen )ang "en&+'+ng 9enge"(angan a9%i'a!i in! &an &ata(a!e. Dengan (er'e"(angna)a (aa!a 9e"r#gra"an ;i!+a% &+'+ngan B#r%an& tera&a9 (aa!a 9e"r#gra"an (er(a!i! $#""an& %ine inter4a$e !e"a'in (er'+rang. Ha% ini &i"an4aat'an #%e ti" freepascal +nt+' "enge"(ang'an 9r#)e' #9en !#+r$e +nt+' "e"(+at a9%i'a!i $#"9i%er )ang '#"9ati(e% &engan T+r(# Pa!$a%. Free9a!$a% "er+9a'an (aa!a 9e"r#gra"an )ang "+%ti9%at4#r" !eingga (i!a (er,a%an +nt+' (er(agai !i!te" #9era!i !e9erti in!< Lin+ &an Ma$ OS. Free Pa!$a% 1./ 9erta"a 'a%i &i ri%i! 9a&a (+%an 7+%i ta+n ///. Free Pa!$a% a&a%a $#"9i%er )ang 'e'+rangann)a a&a%a ti&a' "en&+'+ng IDE &nte"rated evelopment 'nvironment !e9erti De%9i. Ti" 4ree 9a!$a% a'irn)a "enge"(ang'an 9r#)e' Laar+! )ang "er+9a'an IDE &ari Free Pa!$a%< )ang "ena"9i%'an e&it#r '#&e !+"(er!#+r$e $#&e e&it#r< &e(+gger< (er(agai 4ra"e#r' &an 9a'et (eri'+t '#"9#nen 'e9+!ta'aan %i(rar) )ang "iri9 &engan De%9i IDE. Laar+! ;er!i 1./ &i ri%i! 9a&a Ag+!t+! ta+n /1< 'arena !i4atn)a )ang #9en !#+r$e (an)a' !+'are%aan )ang "en+%i!'an 9a'et &an '#"9#nen +nt+' %aar+! &an '#"+nita!n)a te%a (er'e"(ang.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal #
Modul Pemrograman Komputer C. it!r "b#ect Pascal
O(,e$t Pa!$a% a&a%a (aa!a 9e"r#gra" an ting'at tinggi !eingga )ang !angat "+&a +nt+' &i9e%a,a ri #%e !ia9a9+n. C#"9i%er (aa!a Pa!$a% !angat $e9at &an a9%i'a!i0a9%i'a!i )ang a!i%'an !angat re%ia(e%< $e9at &an (i!a &i(an&ing'an &engan (aa!a C ata+ CJJ. Kita &a9at "en+%i!'an a9%i'a!i0a9%i'a!i )ang (e!ar &engan IDE De%9i tan9a "ene"+i '#"9%e'!ita! &a%a" 9en+%i!ann)a. Ma!a%a )ang "+n$+% &a%a" 9engg+naan !#4tare Borland elphi a&a%a (aa +nt+' &a9at "engg+na'an !#4tare ter!e(+t "e"(+t+'an %i!en!i )ang (er(a)ar. Ha% ini tent+n)a "en,a&i 'en&a%a ter+ta"a (agi 'a%angan "aa!i!a. Saat ini (er(agai +9a)a te%a &i%a'+'an +nt+' "engata!i 'en&a%a ter!e(+t< !a%a !at+n)a a&a%a &engan &i(+atn)a !#4tare0!#4tare grati! +nt+' 'a%angan "aa!i!a student version &an !#4tare grati! !a"a !e'a%i #ree(are. S#4tare0!#4tare !e9erti it+ $+'+9 9e!at 9er'e"(angann)a &a%a" &e'a&e tera'ir 'arena a&an)a 9%at4#r" %in+ )ang open source &a%a" arti !e"+a #rang tan9a (ata! &a9at "eng+(a< "e"#&i4i'a!i< "engganti< "engg+na'an &an "en&i!tri(+!i'ann)a !e$ara gati! GNU P+(%i$ Li$en!e :GPL. Sa%a !at+ !#4tare )ang "en&+'+ng a% ter!e(+t a&a%a Laar+!. Laar+! "er+9a'an !#4tare (er(a!i! Pascal )ang &iran$ang +nt+' "e"en+i (er(agai ,eni! 9e"r#gra"an gra4i!. Karenan)a Laar+! &i!e(+t !e(agai '%#ning0n)a De%9i teta9i tent+ !a,a &engan %i!en!i grati!.
D. Algoritma dan lo$ Chart
A%g#rit"a "er+9a'an !+at+ %ang'a0%ang'a &a%a" 9en)e%e!aian !+at+ "a!a%a. Lang'a0%ang'a ter!e(+t &a9at &it+%i! "engg+na' an n#ta!i a9a !a,a< a!a%'an "+&a &i(a$a &an &i"engerti< 'arena ti&a' a&a n#ta!i (a'+ &a%a" 9en+%i!an a%g#rit"a. Setia9 #rang &a9at "e"(+at at+ran 9en+%i!an &an n#ta!i a%g#rit"an)a !en&iri. A%g#rit"a '#"9+ta!i "e!tin)a &i(+at ata+ &i!e!+ai'an &engan (aa!a 9e"ragra"an )ang a'an &ig+na'an &a%a" 9en)e%e!aian "a!a%an)a. Se$ara +"+" a%g#rit"a ter&iri ata! tiga (agian )ait+ %. 7+&+% header
)ait+ (again te'! )ang &ig+na'an +nt+' "en&e4ini!i'an na"a 9r#gra"
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1$
Modul Pemrograman Komputer &. De'%ara!i declaration
)ait+ (agian )ang &ig+na'an +nt+' "en&e4ini!i'an ti9e< '#n!tanta< ;aria(e% &an 4+ng!i ata+ 9r#!e&+r '. A%g#rit"a
)ait+ (agian )ang (eri!i 9erinta09erinta statement )anng ter&iri ata! in9+t:#+t9+t<
a!!ign"ent<
!e+en$e
+r+tan
ana%i!a<
'#n&i!i
&an
9eng+%angan.
Se$ara +"+" a%g#rit"a &a9at &iga"(ar'an &engan "engg+na'an !i"(#%0!i"(#% )ang "+&a &i(a$a &an &i"engerti "engg+na'an &iagra" a%%ir FLO CHART. S+at+ 9r#gra" )ang $+'+9 '#"9%e'! &a9at &iga"(ar'an "engg+na'an Flo( Chart &ari 9r#gra" ter!e(+t. Keg+naan &ari
Flo( Chart !e%ain +nt+'
"e"+&a'an &a%a" 9e"(+atan 9r#gra" ,+ga +nt+' "e"(ant+ #rang %ain )ang ingin "e"9e%a,ari 9r#gra" )ang 'ita (+at. Be(era9a !i"(#% )ang &ig+na'an &a%a" Flo( Chart
Unt+' "e"+%ai $tart ata+ "enga'iri 'nd 9r#gra"
Unt+' "a!+'an &nput
Unt+' !e(+a 9ern)ataan Bloc) $tatement
Unt+' "en)ata'an '#n&i!i 9er$a(angan
Unt+' "en)ata'an &e'%ara!i ;aria(e%< '#n!tanta &%%.
Unt+' "en)ata'an !a"(+ngan ata+ 9eng+(+ng
Unt+' 9eng+(+ng antar a%a"an
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 11
Modul Pemrograman Komputer
Unt+' 9eng+(+ng &an ara antar !i"(#%
Se%ain it+ "a!i (an)a' !i"(#%0!i"(#% %ainn)a. M+ng'in +nt+' 9r#gra" !e&erana !e9erti $#nt# (eri'+t ti&a'%a 9enting "e"(+at F%# $art. Teta9i +nt+' 9r#gra" )ang ,a+ %e(i r+"it ata+ '#"9%e'! F%# Cart a'an !angat (erg+na. Beri'+t a&a%a $#nt# F%# Cart !e&erana +nt+' "engit+ng rata0rata
E. (oal)soal %. Se(+t'an (aa!a 9e"#gra"an )ang 'ita 'eta+i &. A9a'a )ang &i"a'!+& &engan 4%# $art
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 12
Modul Pemrograman Komputer '. Menga9a &a%a" "e"(+at !+at+ 9r#gra" '#"9+ter &ian,+r'an +nt+'
"e"(+at 4%# $art ter%e(i &a+%+ *. B+at%a 4%# $art +nt+' "engit+ng ;arian! &ari 9#9+%a!i &ari r+"+!
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 13
Modul Pemrograman Komputer
Bagian 2 BAHASA PEMROGRAMAN LAZARUS
A. Pengenalan (oft$are La+ar!s
Laar+!
"er+9a'an
9erang'at
9enge"(angan
a9%i'a!i
(er(a!i!
9a!$a%
&i%ing'+ngan Lin+. Da%a" 9er'e"(angann)a Laar+! ,+ga "en&+'+ng (er(agai 9%at4#r" %ain !e9erti in!< Ma$ OS &an S#%ari!. Dengan "engg+na'an 9erang'at %+na' ini 'ita &a9at "e"(ang+n (er(agai a9%i'a!i GUI 9er"ainan< "+%ti"e&ia< &ata(a!e &an %ain0%ain. Dengan 9en&e'atan ;i!+a% 'ita &a9at "en$i9ta'an a9%i'a!i $anggi tan9a (an)a' "en+%i!'an '#&e. Ban)a' (aa!a 9e"9r#gra"an )ang a&a &ea!a ini (ai' )ang (er(a!i! tet CLI "a+9+n gra4i! GUI< (ai' )ang (er(a!i! in!< Lin+< S+n S#%ari! "a+9+n !i!te" #9era!i %ainn)a. Pa&a (aa!an ini )ang a'an &ig+na'an !e(agai 'a,ian )ait+ (aa!a 9e"r#gra"an Laar+!. Perti"(angan 9engg+naan 9r#gra" ini 'arena Laar+! "er+9a'an 9e"9r#gra"an ;i!+a% )ang !angat 'ita% &an "+&a +nt+' &i9e%a,ari. Laar+! "er+9a'an 9enge"(angan &ari Baa!a Pe"r#gra"an Pa!$a% )ang !angat ter'ena% 9a&a Pe"r#gra"an (er(a!i! DOS. Laar+! "er+9a'an !e(+a !#4tare #9en !#+r$e &engan 4ree %i!en!i !eingga 'ita &a9at "en&a9at'ann)a !e$ara "eng+n&+ n)a grati! La+ar!s ,DE (eri'+t ree Pascal Compiler0n)a &i !it+! tt9::%aar+!.4ree9a!$a%.#rg.
Laar+! ter!e&ia +nt+' (er(agai 9%at4#r" (ai' in!< Lin+< S+n S#%ari! "a+9+n Ma$ OS. A9%i'a!i )ang &it+%i! &a%a" Laar+! &a9at &i re0$#"9i%e& 9a&a 9%at4#r" %ain +nt+' "en&a9at'an a9%i'a!i )ang &a9at &ie'!e'+!i 9a&a 9%at4#r" ter!e(+t. Se(agi $#nt# a9a(i%a 'ita "en+%i! a9%i'a!i "engg+na'an Laar+! &a%a" 9%at4#r" in!< &an 'a"+ "engingin'an a9%i'a!i ter!e(+t (i!a &i e'!e'+!i &a%a" Lin+ 'ita tingga% "en)a%in copy '#&e !+"(er source code 'e Laar+! &a%a" Lin+ 'e"+&ian tingga% &i$#"9i%e. Laar+! "e"9r#&+'!i a9%i'a!i a!%i 9a&a !etia9 !i!te" #9era!i< &an ti&a' "e"(+t+'an %i(rar) ta"(aan ata+ "e!in ;irt+a%. O%e !e(a( it+ !angat "+&a +nt+' "en)e(ar'an &an "enge'!e!'+!i !e$ara $e9at. Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 14
Modul Pemrograman Komputer
B. ,nstalasi Program La+ar!s
Se(e%+" &a9at "e"+%ai &an "engg+na'an Baa!a Pe"r#gra"an Laar+!< 'ita ar+! "engeta+i &+%+ &+'+ngan !#4tare ini &a%a" 9%at4#r" a9a. Unt+' 9%at4#r" in! 4i%e in!ta%a!i Laar+! (ere'!ten!i .ee &engan !9a$e !e'itar 6/MB. Per%+ &i'eta+i Baa!a Pe"r#gra"an Laar+! "engg+na'an #(,e'0#(,e' &a%a" Pa!$a% !eingga 'ita ar+! "engeta+i 9erinta09erinta &a!ar &a%a" 9a!$a%. Sete%a "e"+t+!'an 9engg+naan =er!i Laar+! "a'a %ang'a !e%an,+tn)a a&a%a "engin!ta%a!i Pr#gra" Laar+!. Pr#!e! in!ta%a!i 9r#gra" Laar+! $+'+9 "+&a !e9erti 9a&a in!ta%a!i 9r#gra" (er(a!i! in! %ainn)a< tingga% i'+ti 9et+n,+' )ang &i(eri'an 9a&a ta"9i%an &i %a)ar. Unt+' 9engg+na Lin+ 'ita &a9at &engan "+&a "e"9er#%en)a &a%a" !#4tare re9#!it#r). A9a(i%a 'ita "engg+na'an U(+nt+ 'ita tingga% "en+%i!'an 9erinta (eri'+t &i ter"ina%
!+ a9t0get in!ta%% %aar+!
A9a(i%a 'ita "engg+na'an Fera 'ita tingga% "en+%i!'an 9erinta (eri'+t &i ter"ina%
)+" in!ta%% %aar+!
Se!+&a Laar+! terin!ta%a!i 9a&a '#"9+ter< 'ita (i!a "e"+%ai "engena% a9a it+ Laar+!. Laar+! a&a%a '#"9i%er:9enter,e"a (aa!a Laar+! aa%n)a &ari Pa!$a% )ang "er+9a'an (aa!a ting'at tinggi !e'e%a! &engan Ba!i$< F#rtran &an C. Baa!a Pe"r#gra"an Laar+! &i!e(+t (aa!a 9r#!e&+ra% artin)a (aa!a:!inta'n)a "engi'+ti +r+tan tertent+:9r#!e&+r. A&a ,eni! 9e"r#gra"an n#n09r#!e&+ra% !e9erti 9e"r#gra"an +nt+' 'e$er&a!an (+atan !e9erti (aa!a Pr#%#g. Laar+!
ter"a!+'
Ke%+arga
Baa!a
9e"r#gra"an
=i!+a%
)ang
(erarti
9erinta09erinta +nt+' "e"(+at #(,e' &a9at &i%a'+'an !e$ara ;i!+a%. Pe"r#gra" Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 15
Modul Pemrograman Komputer tingga% "e"i%i #(,e' a9a )ang ingin &i"a!+''an 'e&a%a" F#r"< %a%+ ting'a %a'+ #(,e' ter!e(+t !aat "eneri"a e;ent:a'!i tingga% &i(+at 9r#gra"n)a. Laar+! "er+9a'an (aa!a 9e"r#gra"ann (er#renta!i #(,e'< artin)a na"a #(,e'< 9r#9erti &an "et#&e:9r#$e&+re &i'e"a! "en,a&i !at+ 'e"a!an en$a9!+%ate. Se(e%+" "e"9e%a,ari 'etiga !tr+'t+r 9e"r#gra"an a&a (ai'n)a 'ena%i &a+%+ ta"9i%an IDE< )ang "er+9a'an e&it#r &an t##%! +nt+' "e"(+at 9r#gra" Laar+!. Pa&a IDE a'an &ita"9i%'an F#r" (ar+ )ang "er+9a'an a9%i'a!i:9r#gra" in )ang a'an &i(+at. A9%i'a!i:9r#gra" (er(a!i! in! !ering &i!e(+t &engan ,en&e%a in. Bagai"ana "e"(+at a9%i'a!i (er(a!i! in! (er(a!i! gra4i' &an (+'an (er(a!i! te'! Caran)a &engan "e"(+at !e(+a 4#r". Pa&a 9e"r#gra"an (er(a!i! in!< 'ita a'an &i9era&a9'an 9a&a !at+ ata+ (e(era9a ,en&e%a )ang na"9a' &ia&a9an 'ita. 7en&e%a ini &a%a" Laar+! &i!e(+t ,+ga &engan 4#r". Pa&a 9e"r#gra"an (er(a!i! in!< 'ita a'an &i9era&a9'an 9a&a !at+ ata+ (e(era9a ,en&e%a )ang na"9a' &ia&a9an 'ita. 7en&e%a ini &a%a" Laar+! &i!e(+t ,+ga &engan 4#r".
Ga"(ar 1. 7en&e%a Uta"a Laar+!
Pa&a ,en&e%a +ta"a "ain in! ini (eri!i i'#n0i'#n +nt+' "engat+r 9r#gra" )ang a'an &i(+at. Se%ain it+ &a%a" ,en&e%a ini ,+ga (eri!i "en+0"en+ +nt+' "e"(+'a ata+ "en)i"9an #(,e'< "e"(+at "e"(+'a &an "en)i"9an 9r#,e'< "en+ +nt+' e'!e'+!i r+n< 9engat+ran 9engg+naan t#%%!< "en+ e&iting &an "en+ (ant+an e%9. Sa)angn)a Laar+! an)a "en)e&ia'an "en+ (ant+an !e$ara #n%ine &an ti&a' "en)e&ia'an !e$ara #44%ine. Pa&a (agian (aa ,en&e%a ini a&a ta(0ta( )ang (eri!i 9a%et09a%et )ait+ (er+9a #(,e'0#(,e' )ang nantin)a a'an &ite"9at'an &i&a%a" F#r".
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1
Modul Pemrograman Komputer
Ga"(ar . 7en&e%a E&it#r S+"(er S#+r$e E&it#r
Pa&a ,en&e%a !#+r$e e&it#r ini '#&e0'#&e 9r#gra" a'an &it+%i!'an.
Ga"(ar 3. 7en&e%a Pe!an Me!!age!
Me!!age! "er+9a'an ,en&e%a )ang nantin)a a'an (eri!i !e"+a 9e!an 'e!a%aan err#r< 9eringatan arning "a+9+n 'eterangan !+'!e! ti&a'n)a 9r#gra" )ang &i,a%an'an. 7en&e%a %ainn)a a&a%a F#r" )ait+ te"9at 'ita "e"(+at 9r#gra" &an O(,e$t in!9e$t#r )ait+ ,en&e%a +nt+' "engat+r #(,e' )ang &ite"9at'an &i &a%a" F#r". Unt+' 'e&+a ,en&e%a ini a'an &i,e%a!'an 9a&a (agian !e%an,+tn)a.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1!
Modul Pemrograman Komputer Laar+! a&a%a !e(+a 9erang'at %+na' (aa!a 9e"r#gra"an +nt+' "e"(+at 9r#gra" : a9%i'a!i '#"9+ter (er(a!i! in!. Laar+! "er+9a'an (aa!a 9e"#gra"an (er(a!i! #(,e'< artin)a !e"+a '#"9#nen )ang a&a "er+9a'an #(,e'0#(,e'.
Ciri
"et#&:9r#$e&+re.
!e(+a Laar+!
#(,e'
a&a%a
&i!e(+t
,+ga
"e"i%i'i visual
na"a<
9r#9erti
pro"rammin"
&an artin)a
'#"9#nen0'#"9#nen )ang a&a ti&a' an)a (er+9a te'! )ang !e(enarn)a 9r#gra" 'e$i% teta9i "+n$+% (er+9a ga"(ar0ga"(ar.
C. -emb!at (eb!ah orm
Saat 'ita 9erta"a 'a%i "a!+' 'e Laar+!< 'ita a'an &i9era&a9'an a&a !e(+a 4#r" '#!#ng )ang a'an &i(+at !e$ara #t#"ati!. F#r" ter!e(+t &i(eri na"a orm%. F#r" ini "er+9a'an te"9at (e'er,a +nt+' "e"(+at antar"+'a
9engg+na.
Ga"(ar . F#r" K#!#ng Pa&a !aat "a!+' Laar+!
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1"
Modul Pemrograman Komputer D. -engganti Nama orm dan -enambahkan !d!l
Bia!a'an !e(e%+" "en,a%an'an 9r#gra"< !e(ai'n)a ganti na"a 4#r" &an (eri ,+&+% !e!+ai 9r#gra" )ang 'ita (+at. Laar+! a'an !e$ara #t#"ati! "e"(eri na"a 4#r"1< 4#r"< 4#r"3< &!t. Na"a 4#r" ter!e(+t '+rang "engan&+ng arti &an a'an "en)+%it'an (i%a 4#r" )ang &i(+at $+'+9 (an)a'. Saat "e"(+'a Laar+! 9erta"a 'a%i< na"9a' !e(+a ,en&e%a "b#ect ,nspector. 7i'a ti&a' "+n$+% 9i%i "en+ Vie( * Ob!ect &nspector ata+ te'an t#"(#% F11. Pa&a Ob!ect &nspector a&a &+a (+a a%a"an ta( )ait+ Pr#9ertie! &an E;ent!. Properties
&ig+na'an
+nt+'
"engganti
9r#9erti
'e9e"i%i'an
!e(+a
#(,e':'#"9#nen. Se&ang'an E/ents &ig+na'an +nt+' "e"(+at 9r#$e&+re )ang &ia'ti4'an trigere& %eat !e(+a e;ent.
Ga"(ar 5. Ta"9i%an O(,e$' In!9e$t#r Unt+' Pengat+ran Pr#9erti &an e;en
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1#
Modul Pemrograman Komputer Se"+a 9r#9erti &i+r+t'an (er&a!ar'an a%9a(eti'< &an &a9at ,+ga &i+r+t'an (er&a!ar'an 'ateg#ri. Ganti%a ,+&+% 4#r" &engan He%%# "e%a%+i 9r#9erti Caption< !e&ang'an na"a 4#r" &engan na"a 4r"He%%# "e%a%+i 9r#9erti Name. Ca9ti#n &ig+na'an +nt+' "en)i"9an 'eterangan )ang &i"+n$+%'an 9a&a 4#r"< !e&ang'an Na"e &ig+na'an !e(agai Na"a &ari #(,e' ter!e(+t. I!i &ari 9r#9erti Na"e ar+! &iaa%i a%9a(et &an ti&a' "engg+na'an !9a!i ata+ tan&a (a$a 'ita !e'arang !+&a "e"(+at a9%i'a!i 4#r" '#!#ng &engan t#"(#% !tan&ar in Mini"ie< Mai"ie< &an C%#!e. 'ita &a9at "eng+(a +'+ran 4#r" &engan "enari' 9a&a (ing'ai 4#r" "engg+na'an "#+!e dra"'%i' t#"(#% 'iri "#+!e< taan t#"(#% ter!e(+t %a%+ ge!er 'e 'iri:'anan ata+ ata!:(aa. 'ita &a9at "e"in&a'an 4#r" &engan "e%eta''an '+r!#r 9a&a 4#r" 'e"+&ian "engge!ern)a &rag. -enyimpan orm
Pa&a Laar+! a&a 3 (+a 4i%e +ta"a 0.dpr< 0.pas &an 0.dfm. 1 .dpr a&a%a 4i%e 9r#)e' )ang &i(+at (eri!i 9r#gra" 'e$i% +nt+' •
Men&e4ini!i'an Unit )ang a&a &a%a" 4i%e 9r#)e'
•
Mengini!ia%i!a!i &ata
•
Me"(ang+n 4#r"
•
Men,a%an'an a9%i'a!i
!ses orms1 Unit% in 2Unit%.pas3 4orm%56 begin Application.,nitiali+e6 Application.Createorm78form%1 orm%96 Application.:!n6 end.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 2$
Modul Pemrograman Komputer .pas a&a%a +nit0+nit pascal code #ile< )ang "er+9a'an '#&e 9r#gra" )ang 'ita t+%i!'an +nt+' "enge'!e'+!i e;en. Unit '#&e 9r#gra" 9a!$a% ini (i!a ter&iri !at+ ata+ (an)a' 4i%e 3 .dfm a&a%a 4i%e &e4ini!i F#r" special pseudo code #ile< (i!a ter&iri !at+ ata+ (an)a' 4i%e
ob#ect orm%; 8form% Left < &== 8op < %=> ?idth < @@ Height < *>= Caption < 2orm%3 ont.Charset < DEAUL8CHA:(E8 ont.Color < cl?indo$8et ont.Height < )%% ont.Name < 2-( (ans (erif3 ont.(tyle < PielsPer,nch < @ 8etHeight < %' ob#ect B!tton%; 8b!tton Left < %F@ 8op < %%@ ?idth < FG Height < &G Caption < 2B!tton%3 8ab"rder < = end end
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 21
Modul Pemrograman Komputer
Catatan
$etiap Form .d#m harus memili)i sebuah -nit .pas, tetapi )ita dapat memili)i -nit tanpa sebuah Form hanya )ode sa!a. i)a in"in melihat )ode tersebut )ita dapat men")li) )anan mouse, lalu pilih VIEW AS TEX T atau te)an tombol
Alt-F12. $ebai)nya )ita tida) men"ubah isi code tersebut, )arena a)an menyebab)an masalah serius. Tun""u saat )ita sudah memahami ma)sud )ode tersebut. -ntu) )emba li )e bentu) #orm, pilih VIEW AS FOR M atau te)an tombol Alt- F12 )embali.
Unt+' "en)i"9an 9r#gra" &a%a" Laar+! &a9at &i%a'+'an &engan "e"i%i !+("en+ (a/e Pro#ect ata+ (a/e Pro#ect As 9a&a "en+ Fi%e< &an Laar+! a'an "enan)a'an na"a 4i%e !#+r$e $#&e +nt+' +nit .9a! &an na"a 4i%e 9r#)e'n)a .&9r. Beri na"a 4i%e 4#r" &enga n lat%.pas &an 9r#,e$t latihan%.lpi Se!+&a &i!i"9an< ,a%an'an 9r#gra " &engan "ene'an t#"(#% F- ata+ 9i%i "en+ %un * %un.
E. -enempatkan omponen pada orm
Karena
Laar+!
"er+9a'an
(aa!a
9e"r#gra"an
;i!+a%<
"a'a
'#"9#nen0'#"9#nen a'an na"9a' 9a&a %a)ar. 'ita tingga% "ene"9at'an '#"9#nen )ang &iingin'an 9a&a 4#r". A&a e"9at $ara "ene"9at'an '#"9#nen 9a&a 4#r". Mi!a% 'ita "e"i%i '#"9#nen utton 9a&a Component! "alette (agian Stan#ar# "a$e. 'ita &a9at "e"i%i !a%a !at+ %ang'a (eri'+t •
K%i' 9a&a '#"9enen ter!e(+t< 9in&a'an '+r!#r 'e 4#r"< !a"(i% "ene'an t#"(#% 'iri "#+!e &rag '#"9#nen &an ge!er 9a&a 4#r" ata+
•
Pi%i '#"9#nen '%i' '#"9#nen )ang &iingin'an 9a&a Component!
"alette 'e"+&ian '%i' 9a&a 4#r" &i"ana '#"9#nen it+ a'an &i%eta''an. •
K%i' gan&a 9a&a '#"9#nen )ang &iingin'an< "a'a '#"9#nen ter!e(+t a'an &ita"(a'an 9a&a 4#r"
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 22
Modul Pemrograman Komputer •
'ita &a9at "engg+ na'an Copy &an Paste (i%a ingin "e"(+at '#"9#nen )ang !a"a )ang !+&a a&a 9a&a 4#r". Caran)a Si4t0K%i' 'iri 9a&a '#"9#nen )ang a&a &i 4#r"< %a%+ 9i%i "en+ Copy Ctr%0C 'e"+&ian 9i%i "en+ Paste Ctr%0=.
Ga"(ar 6. K#"9#nen @ang a&a &i Laar+!
. -engat!r 8ataletak omponen
Pa&a 4#r" ini an)a a&a !at+ (+tt#n< "+ng'in a&a &i (agian tenga 4#r". 'ita &a9at "engat+r %eta' '#"9#nen ter!e(+t &engan "engge!ern)a. Bi%a 'ita ingin "era9i'an 9i%i "en+ Iie$ J Anchor Editor < "a'a "+n$+% !e(+a T##%(# An$#r &engan i'#n 9era9ian
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 23
Modul Pemrograman Komputer
Ga"(ar *. K#ntr#% +nt+' O(,e'
Dengan t##%(# ini 'ita &a9at "era9i'an (e(era9a '#"9#nen !e'a%ig+!< $aran)a (+at 4#'+! (e(era9a '#"9#nen< %a%+ '%i' i$#n 9a&a t##%(# )ang &iingin'an. Unt+' "engeta+i arti i$#n ter!e(+t gera'an "#+!e 9a&a t#"(#% ter!e(+t< %a%+ a'an "+n$+% 9en,e%a!an !ing'at 'eg+naan i$#n ter!e(+t ata+ %iat He%9 te'an F1. 'ita (i!a "e"9e%a,arin)a !en&iri. C+'+9 "+&a. Lang'a )ang 9enting a&a%a "eng+(a na"a &an 'eterangan '#"9enen (+tt#n ter!e(+t. I'+ti (agian ini
K. -eng!bah Nilai Properti
U(a ni%ai 9r#9erti Caption "en,a&i /ata)an 0ello &an ni%ai 9r#9erti Name "en,a&i btn0ello. Lang'a ini "iri9 &engan "eng+(a na"a &an 'eterangan !e(+a 4#r". Setia9 '#"9#nen !e(ai'n)a &i(eri na"a )ang "e"i%i'i arti &an &iaa%i #%e ,eni! '#"9#nenn)a. Mi!a% na"a &ari 4#r" He%%# a&a%a 4r"He%%# ata+
na"a
&ari
(+tt#n
He%%#
a&a%a
(tnHe%%#.
T+,+ann)a
a&a%a
"enge%#"9#''an '#"9#nen0'#"9#nen !e,eni!< 'arena 9a&a O(,e$t In!9e$t#r na"a '#"9#nen &i+r+t' an (er&a!ar'an a%9a(et. Pr#9erti name a&a%a 9r#9erti interna% &an &ig+na'an +nt+' "e"(eri na"a 9a&a !e(+a '#"9#nen:#(,e'. Na"a ini a&a%a !e(+a ;aria(e% )ang "enga$+ 9a&a '#"9#nen ter!e(+t. Be(era9a at+ran 9ena"aan '#"9#nen ata+ ;aria(e% ata+ i&enti4er !e(agai (eri'+t •
Diaa%i a%9a(et< (eri'+tn)a (#%e ang'a< gari! (aa.
•
Ti&a' "e"a'ai !9a!i ata+ tan&a0tan&a (a$a ata+ #9erat#r 'e$+a%i gari! (aa
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 24
Modul Pemrograman Komputer •
B#%e +r+4 'a9ita% ata+ 'e$i%< ti&a' a&a 9er(e&aan
•
Ti&a' "engg+na'an 'ata '+n$i reserve (ord )ang &ig+na'an Laar+!
•
Bia!a'an na"a '#"9#nen &iaa%i 'e%#"9#' '#"9#nenn)a< "i!a% (tnHe%%#< 4r"He%%#< rgrKe%a!.
Beri'+t $#nt# 9ena"aan )ang 'e%ir+ "engg+na'an !9a!i
Ga"(ar 8. C#nt# Pena"aan '#"9#nen )ang !a%a "engg+na'an !9a!i
Ga"(ar -. C#nt# Pena"aan '#"9#nen )ang (enar "engg+na'an gari! (aa
Kita &a9at "e"(+at na"a #(,e' )ang ter%iat 9a&a F#r" &engan "engg+na'an Caption &a%a" ob!ect inspector. Da%a" $a9ti#n ti&a' a&a at+ran &a%a" "engi!i
te'! !e9erti &a%a" na"e. Seingga +nt+' b!ttonhello )ang ta&i 'ita (+at Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 25
Modul Pemrograman Komputer "i!a%n)a 'ita (i!a "engi!in)a &engan T#"(#% He%%# "engg+na'an !9a!i &an +nt+' orm% &a9at 'ita i!i! &engan Pr#gra" He%%#. Ha!i%n)a a'an ter%iat &i &a%a" F#r".
Ga"(ar 1/. Me"(+at $a9ti#n +nt+' F#r" &an (+tt#n
H. -emb!at -ethodProced!re le$at E/ent
Saat 'ita "ene'an t#"(#% 9a&a !e(+a 4#r" ata+ '#"9#nen< in! "e"(erita+'an (aa a9%i'a!i "engiri" 9e!an )ang &i(ang'it'an #%e e;ent tertent+ . Laar+! a'an "enangga9i &engan "eneri"a e;ent ata+ 9anggi%an ter!e(+t. Ha% ini )ang &ina"a'an 9enanganan e;ent event1handler method. Laar+! "en&e4ini!i'an !e,+"%a e;ent 9a&a !etia9 '#"9#nenn)a. Da4tar e;ent ini (e(e&a +nt+' !etia9 '#"9#nen. E;ent )ang 9a%ing +"+" 9a&a '#"9#nen B+tt#n a&a%a OnC%i$'. Artin)a ,i'a '#"9#nen B+tt#n ter!e(+t &i K%i' "a'a a'an "e%a'+'an 9r#$e&+re a9a. A&a (e(era9a te'ni' )ang &a9at &i%a'+'an +nt+' "enangani e;ent "i!a% OnC%i$' 9a&a '#"9#nen (+tt#n •
K%i' gan&a 9a&a (+tt#n ter!e(+t< "a'a !e(+a "et#&:9r#$e&+re (tnHe%%#C%i$'
•
Pi%i (+tt#n< 'e"+&ian 9i%i O(,e$t In!9e$t#r! $#"(# (# called the Ob!ect $elector< 9i%i Ta( E;ent!< &an '%i' gan&a 9a&a area 9+ti &i!e(e%a 'anan e;ent OnC%i$'
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 2
Modul Pemrograman Komputer •
Pi%i (+tt#n< 9i%i Ta( E;ent!< &an "a!+''an na"a "et#& )ang &i'een&a'i< "i!a% (+tt#nQHe%%#C%i$' 9a&a area 9+ti &i !e(e%a 'anan e;ent OnC%i$'
Ga"(ar 11. K#&e !+"(er +nt+' (+tt#nQHe%%#C%i$'
Bi%a 'ita ingin "enga9+! 9r#$e&+re ata+ 9enanganan e;ent ter!e(+t< 'ita &a9at "enga9+! 9a&a e&it#r Unit ter!e(+t. Ha9+! (%#' 9r#$e&+re ter!e(+t &an a9+! 9a&a (agian &e4ini!i 9r#$e&+re )ang a&a &iata!n)a. Se'arang 'ita "engi!i 9r#$e&+re ter!e(+t &engan 9erinta +nt+' "ena"9i%'an 9e!an !e(agai (eri'+t
proced!re TF#r"1.B+tt#nQHe%%#C%i$'Sen&er TO(,e$t begin
Me!!ageD%g
A!!a%a"+ a%ai'+"< "tIn4#r"ati#n< "(OK< /
end
Perinta -essageDlg ini !angat !e&erana< )ait+ +nt+' "ena"9i%'an 9e!an. F+ng!i -essageDlg ini "e"9+n)ai e"9at 9ara"eter. Unt+' rin$in)a 'ita &a9at Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 2!
Modul Pemrograman Komputer "e%iat Bant+an F1. •
Para"eter 9erta"a
'a%i"at )ang a'an &i"+n$+%'an 9e!ann)a
•
Para"eter 'e&+a
ti9e "e!!age (# !e9erti "tarning< "tErr#r<
"tIn4#r"ati#n< ata+ "tC#n4ir"ati#n. C#(a %iat 9er(e&aann)a. •
Para"eter 'etiga
'+"9+%an t#"(#% )ang a'an &ig+na'an !e9erti
"(@e!< "(N#< "(OK< "(Can$e%< ata+ "(He%9. •
Para"eter 'ee"9at
+nt+' e%9 $#ntet ata+ n#"#r a%a"an 9a&a He%9<
(eri ang'a n#% ,i'a 'ita ti&a' "e"9+n)ai 4i%e e%9.
,. o-pilasi dan alankan Program
Te'an t#"(#% R+n t#"(#% !egitiga (erarna i,a+ &i !e(e%a 'iri ata! ata+ 9i%i "en+ %un * %un ata+ Te'an , Laar+! a'an "en,a%an'an 9erinta (eri'+t ini 1. K#"9i%a!i Pa!$a% !#+r$e $#&e 4i%e )an g "en&e4ini!i'an 4#r"04#r" )ang a&a .9a!< .&4" . K#"9i%a!i 9r#,e$t 4i%e .&9r 3. B+at ee$+ta(%e .E?E 4i%e . Men,a%an'an ee$+ta(%e 4i%e< (ia!an )a 9a&a "#&e 9en$ arian 'e!a%aan &e(+g "#&e. Sete%a 9r#gra" ee$+ta(%e ,a%a" "a'a a'an "+n$+% ,en&e%a !e9erti (eri'+t ini
Ga"(ar 1. Pr#gra" He%%# !ete%a &i,a%an'an
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 2"
Modul Pemrograman Komputer
&an a9a(i%a 'ita '%i' 8ombol Hello a'an "+n$+% ,en&e%a !e9erti (eri'+t
Ga"(ar 13. C#nt# a!i% 9r#gra" !e&erana
. Ur!tan Perintah
C#"9i%er Laar+! a'an "e"9r#!e! !e"+a 9erinta09erinta &a%a" '#&e !+"(er !e$ara (er+r+tan. Mi!a%n)a 'ita "e"i%i'i 3 (ari! 9erinta "a'a C#"9i%er a'an "e"r#!e! "+%ai &ari (ari!01< (ari!0 &an 'e"+&ian (ari!03. C#nt# 9r#gra" +nt+' "ena"9i%'an 9e!an !e(an)a' 3 'a%i !e9erti (eri'+t
Me!!ageD%g A!!a%a"+ a%ai'+"< "tIn4#r"ati#n< "(@e!< / Me!!ageD%g Se%a"at Pagi< "tC#n4ir"ati#n< "(OK< / Me!!ageD%g Pagi )ang $era< "tarning< "(Can$e%< / $%#!e
Ma'a 9a&a #+t9+tn)a a'an &ita"9i%'an 9e!an 9erta"a A!!a%a"+ a%ai'+" &engan %#g# in4#r"a!i &an t#"(#% @ e!< a9a(i%a &i '%i' t#"(#% @e! "+n$+% 9e!an 'e&+a Se%a"at Pagi &engan %#g# '#n4ir"a!i &an t#"(#% OK &an a9a(i%a &i '%i' t#"(#% OK "a'a a'an "+n$+% 9e!an Pagi )ang $era &engan %#g# arning &an t#"(#% Can$e%. A9a(i%a &i '%i' Can$e% 9r#gra" a'an tert+t+9.
Latihan %
Beri'+t %atian 'e01 +nt+' tiga (+a a9%i'a!i )ait+ "e"(+at t#"(#% He%%#< !aat &i'%i' t#"(#%n)a< t#"(#% a'an (era'!i &engan "e"+n$+%'an 9e!an. I'+ti %ang'an)a !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 2#
Modul Pemrograman Komputer 1. B+at 4#r" 4r"He%%#1 !e9erti )ang !+&a &i,e%a!'an. •
K#"9#nen )ang &i(+t+'an 4#r" &engan na"a frmHello% &an (+tt#n &engan na"a btnHello%. U(a 9r#9erti name0n)a
•
U(a
9r#9erti
caption
"a!ing0"a!ing
'#"9#nen
"en,a&i
-emb!at program Hello% &an atakan Hello •
B+at "et#& &ari '#"9#nen (tnHe%%#1 %eat e;ent OnClic), !e9erti (eri'+t
proced!re T4r"He%%#1.(tnHe%%#1C%i$'Sen&er
T#(,e$t begin
Me!!ageD%g VA!!a%a"+ a%ai'+"< "tIn4#r"ati#n< "(OK< / end •
7a%an'an 9r#gra" %iat a!i%n)a
•
C#(a ganti 9ara"eter 'e01< 'e0 &an 'e03
•
Si"9an &engan na"a +ni t u0ello2.pas &an 9r#,e$t p0ello2.dpr 9a&a &ire't#ri DWM#&+% Data(a!eW
. B+at a9%i'a!i (ar+ Fi%e0Ne0A99%i$ati#n &eng an 4#r" (ar+ 4r"He%%# "iri9 4#r" 4r"He%%#1 &engan ta"(aan !e(agai (eri'+t. A9a )ang ter,a&i 9r#9erti $a9ti#n &ari '#"9#nen t#"(#% &iganti !aat 9r#gra" (er,a%an •
K#"9#nen )ang &i(+t+'an 4#r" &engan na"a frmHello& &an (+tt#n &engan na"a btnHello&. U(a 9r#9erti name0n)a
proced!re 8frmHello&.btnHello&Click 7(ender; 8ob#ect96 begin -essageDlg 72Assalam! alaik!m31 mt,nformation1 mb"1 =96 end6
. -en! dan Perintah pada La+ar!s
A&a e"9at $ara +nt+' "e"(eri 9erinta 9a&a %ing'+ngan Laar+! Laar+! Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 3$
Modul Pemrograman Komputer en;ir#n"ent %. G+na'an "en+ &. G+na'an S#rt C+t "i!a% F-< F1 &!( '. G+na'an S9ee&Bar ata+ t##%(ar. *. G+na'an S9ee&Men+ %#'a% "en+ )ang &ia'ti4'an &engan t#"(#% "#+!e
'anan. Beri'+t "en+ +ta"a )ang a&a 9a&a Laar+! +nt+' "e"9e%a,arin)a g+na'an He%9 Laar+!
•
-en! ile. Men+ ini (er+(+ngan &engan 4i%e !e9erti "e"(+at<
"en)i"9an &an "enga'iri !e(+a 9e'er,aan.
•
-en! Edit .Men+ ini (er+(+ngan &engan 9en)+ntingan a9a )ang
&i'er,a'an !e9erti Un < Re< C+t< C#9)< Pa!te ata+ &a9at &engan t#"(#% Ctr%J2< Ctr%J?< Ctr%JC< Ctr%J=.
•
-en! (earch. Men+ ini (er+(+ngan &engan 9en$arian &an 9enggantian
&ata.
•
-en! Iie$. Men+ ini (er+(+ngan &engan 9ena"9i%an ata+ a9a )ang
a'an &ita"9i%'an.
•
-en! Pro#ect. Men+ ini (er+(+ngan &engan 9r#)e' )ang !e&ang &i(+at<
"i!a% +nit )ang a'an &ita"(a'an 'e 9r#)e' ini< +nit a9a )ang a'an &ia9+!< &!(.
•
-en! :!n. Men+ ini (er+(+ngan &engan "en,a%an'an 9r#gra"< "en$ari
'e!a%aan &e(+g< &!(.
•
-en! Component. Men+ ini (er+(+ngan &engan '#"9#nen< "i!a%
"ena"(a '#"9#nen (ar+<
•
-en! Database. Men+ ini (er+(+ngan &engan Data(a!e< Data(a!e F#r" iar& &an Data(a!e
•
-en! 8ools. Men+ ini (er+(+ngan &engan 9engat+ran:'#n4ig+ra!i<
t##%0t##% 9e"(ant+ Laar+!.
•
-en! Help. Men+ ini (er+(+ngan &engan in4#r"a!i "engenai Laar+!<
He%9 : (ant+an Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 31
Modul Pemrograman Komputer
L. Component% "roperty% Met&o#% E'ent
K#&e )ang a'an &i%iat 9a&a Laar+!< !er+9a &engan !tr+'t+r Baa!a Pa!$a%. Laar+! a&a%a (aa!a 9e"r#gra"an (er(a!i! #(,e' Component< artin)a 9en&e'atan 9e"(+atan 9r#gra" "e%a%+i #(,e'0#(,e' )ang a&a "i!a%n)a #(,e' 4#r"< tet< (+tt#n &an !e(agin) a. Setia9 #(,e' a'an "e"i%i'i properti atri(+t &an method )ang &ia'ti4'an:&i9i$+ #%e e/ent. Mari 'ita %iat 9en,e%a!an (eri'+t.
%. "b#ek 7C"-P"NEN89
Se(+a '#"9#nen "er+9a'an !e(+a #(,e'
◦ Se(+a O(,e'< a&a%a !e(+a '#"9#nen &a%a" Component Palette<
◦ Ata+ !e!+at+ )ang &i(+at "e%a%+i '#&e0'#&e : (aa!a 9e"r#gra"an 7a&i !e$ara +"+" !e(+a #(,e' a&a%a 'e%a! &ari '+"9+%an !e!+at+. K#"9#nen 9a!ti #(,e'< na"+n #(,e' ti&a' !e%a%+ "er+9a'an '#"9#n en< "i!a% T!tringLi!t a&a%a !e(+a #(,e' '+"9+%an 'ara'ter< &an (+'an !e(+a '#"9#nen.
&. P:"PE:8M 7Atrib!t9
Se(+a Pr#9ert) ti&a' %ain a&a%a !e(+a na"a:;aria(e% "i%i' !e(+a #(,e':'#"9#nen "i!a% Ca9ti#n< Tet )ang &a9at &i+(a ni%ai (ai' "e%a%+i #(,e$t In!9e$t#r ata+ "e%a%+i 9r#gra". Be(era9a i!ti%a: na"a (eri'+t )ang "iri9< &an !ering &ig+na'an
•
Proced!re a&a%a '+"9+%an 9erinta )ang "e%a'+'an !+at+ 9r#!e!
tertent+
•
!nction a&a%a !a"a &engan 9r#$e&+re< teta9i 9r#!e! ter!e(+t &a9at
"enge"(a%i'an !+at+ a!i% : ni%ai "i!a% a!i%n)a 1
•
-ethod a&a%a 9r#$e&+re ata+ 4+n$ti#n )ang terga(+ng 9a&a !e(+a
'#"9#nen
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 32
Modul Pemrograman Komputer
•
(!bro!tine
a&a%a
i!ti%a
+"+"
&ari
!e"+an)a
9r#$e&+re:4+n$ti#n:"et#& "i!a% 9a&a (aa!a Ba!i$.
'. -E8H"D 7-etode9
Se(+a "et#& a&a%a !e(+a 4+ng!i #unction )ang terga(+ng &a%a" !e(+a #(,e'. C#nt# Li!tB# &a9at (erarti !e(+a arra) #4 !tring! )ang "e"i%i'i Met#& C%ear )ang "e"(+at Li!t(# ter!e(+t "en,a&i '#!#ng. CLEAR a&a%a !e(+a Met#& 9a&a Li!tB# ter!e(+t.
Begin ListBo%.Clear6 -engosongkan isi ListBo ListBo%.,tems.Loadromile72c;Data%.tt396 properti ,tems 7bertipe string9 memiliki method !nt!k Loadromile end6
*. EIEN8 7Aksi9
Se(+a E;ent a&a%a !e(+a a'!i 9engg+na U!er A$ti#n "i!a% M#+!e C%i$'< Ke)Pre!!e&. Setia9 E;ent! &iaa%i &engan 'ata VOn. C#nt# Nama e/ent
Nama method
OnC%i$' ..
B+tt#n1C%i$'Sen&er T#(,e$t
OnKe)D#n ..
B+tt#n1Ke)D#nSen&er T#(,e$t
OnM#+!eM#;e ..
B+tt#n1M#+!eM#;eSen&er T#(,e$t
OnCreate
TF#r"1.F#r"CreateSen&er T#(,e$t
Dan %ain !e(again)a
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 33
Modul Pemrograman Komputer -. Cara La+ar!s Beker#a
Saat 'ita "ena"(a'an C#"9#nent! 9a&a F#r"1 &an "er+(a ni%ai 9r#9erti< Laar+!
a'an
"e"(+at
'#&e
pseudo
code
&a%a"
Unit1.&4"
+nt+'
"en&e4ini!i'an a9a )ang 'ita %a'+'an. Unt+' 9e"(+atan 9r#gra" !tan&ar< 'ita TIDAK DIHARAPKAN MENGUBAH Fi%e Unit1.&4". Dengan &e"i'ian &a9at &i'ata'an (aa 'ita an)a (e'er,a 9a&a orm% &an "e%a'+'an 9er+(aan !e$ara =i!+a% (+'an %ang!+ng &ari '#&e !+"(ern)a. Ha% Ini a'an "e"+&a'an 'ita &engan ti&a' 9er%+ "enga4a% !e$ara %eng'a9 '#&e0'#&e !+"(er &ari !etia9 #(,e' teta9i $+'+9 &engan "enga4a%'an na"a0na"a #(,e' &an 4+ng!i04+ng!i &ari 9r#9erti< e;ent &an "et#&n)a. M#&e% (aa!a 9e"r#gra"an !e9erti ini%a )ang &ina"a'an (aa!a 9e"r#gra"an =i!+a% Visual Pro"rammin"
La+ar!s ,DE •
Laar+! IDE a&a%a !e(+a =i!+a% Inter4a$e antara U!er &engan K#"9+ter 'ita )ang (er,a%an &iata! !i!te" #9era!i )ang &i,a%an'an.
•
Laar+! "enter,e"a'an =i!+a% C#"9#nent! B+tt#n!< Pane%!<.. )ang a&a 9a&a F#r" 'e&a%a" !e(+a '#&e0'#&e '#"9+ter 9!e+ $#&e &a%a" Unit1.&4" )ang "en&e4ini!i'an (agai"ana &i(ent+'n)a 4#r" &an '#"9#nenn)a ter"a!+' ,+ga 9r#9ertin)a.
-engkompilasi program 7Compiler9 •
Laar+! a'an "e"anggi% 4i%e .&9r 4i%e 4i%e 9r#)e' 'ita
•
Laar+! "e"inta 9r#gra" )ang a&a &a%a" 9r#)e' ter!e(+t &an 4i%e &9r "e"(eri'an !e(agai (eri'+t !ses orms1 Unit% in 2Unit%.pas3 4orm%56
•
Laar+! "e"inta< A9a )ang &i%a'+'an 9erta"a 'a%i .&9r 4i%e "e"(eri'an !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 34
Modul Pemrograman Komputer begin Application.,nitiali+e6 itiali+es st!ff Application.Createorm78form%1 orm%96 Application.:!n6 end.
N. Beberapa "b#ek dan -ethod
•
orm
Se$ara &e4a+%t !e(+a pro!ect Laar+! an)a "e"(eri'an !e(+a F#r". Teta9i &a%a" "e"(+at 9r#gra" 'ita &a9at (e'er,a &engan "ena"(a'an (e(era9a 4#r" 9a&a !e(+a pro!ect. Be(era9a e;ent )ang (i!a &ig+na'an !aat (era&a 9a&a !e(+a F#r" "i!a%n)a F#r"1 a&a%a
◦ Form2.S&o() +nt+' "e"(+'a $ho(s F#r" teta9i +!er &ii,in'an +nt+' &a9at "eng'%i' F#r"1
◦ Form2.S&o(Mo#al) Unt+' "e"(+'a $ho(s F#r" teta9i +!er ti&a' &ii,in'an +nt+' "eng'%i' F#r"1
•
-enampilkan Pesan 7-essage9
•
S&o(Me!!a$e7O,ni kotak pesanO96 Ta"9i%an !e&erana !e(+a (ari!:te'!. Pe!an &it+%i!'an &i&a%a" '+r+ng &engan "engg+na'an tan&a 9eti' .... . Unt+' 'e%+ar &ari '#ta' 9e!an messa"e (indo( +!er &a9at "ene'an t#"(#% OK .
•
Me!!a$e*l$7O,si kotak pesanO18-sgDlg8ype1msgDlgBtn1=96 Miri9 (ho$-essage ta9i &a9at %e(i &ari !at+ t#"(#% 9i%ian.
,f -essageDlg7OPlease say ME( or N"O1 mtConfirmation1 mbMes1mbNo1=9
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 35
Modul Pemrograman Komputer 8-sgDlg8ype
"tarning<
"tErr#r<
"tIn4#r"ati#n<
"tC#n4ir"ati#n< "tC+!t#" msgDlgBtn "(@e!< "(N#< "(OK< "(Can$e%< "(A(#rt<
"(Retr)< "(Ign#re< "(A%%< "(He%9 :et!rn /al!es "rN#ne< "r@e!< "rN#< "rO'< "rCan$e%<
"rA(#rt< "rRetr)< "rIgn#re< "rA%%
•
,np!t Bo 7otak inp!t9
Inputo+7O !d!l ,np!t O 1 O Apa yang akan di inp!t O 1 Onilai defa!ltO9 /ar ,np!t(tring; string6 begin ,np!t(tring;< ,np!tBo7O-as!kkan NamaO1 OPlease Enter yo!r NameO1OO96 end6
". (oal)soal %. B+at%a !e(+a 9r#gra" +nt+' "eng+(a $a9ti#n &ari F#r" "engg+na'an
in9+t(#. &. B+at%a !e(+a 9r#gra" &engan e"9at (+a t#"(#% )ang "ana
"a!ing0"a!ing t#"(#% "e"9+n)ai 9erinta !e(agai (eri'+t a T#"(#% 1 (erna"a Ca9ti#n "e"erinta'an +nt+' "eng+(a $a9ti#n T#"(#% "en,a&i In4#r"a!i< T#"(#% 3 "en,a&i Peringatan &an T#"(#% "en,a&i K#n4ir"a!i ( T#"(#% (erna"a T#"(#% "e"erinta'an +nt+' "ena"9i%'an '#ta' &ia%#g &engan %#g# In4#r"ati#n &an (+tt#n @e! $ T#"(#% 3 (erna"a T#"(#% 3 "e"erinta'an +nt+' "ena "9i%'an '#ta' &ia%#g &engan %#g# arning &an (+tt#n OK & T#"(#% (erna"a T#"(#% "e"erinta'an +nt+' "ena"9i%'an '#ta' &ia%#g &engan %#g# C#n4ir"ati#n &an (+tt#n Can$e% Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 3
Modul Pemrograman Komputer
MODUL 2 OBJEK PASCAL DALAM LAZARUS
PENDAHULUAN
Da%a" "#&+% ini a'an &i9e%a,ari "engenai #(,e' Pa!$a% )ang &ig+na'an &a%a" !#4tare Laar+! "e%i9+ti ;aria(e%< '#n!tanta< #9erat#r "ate"ti'a &an #9erat#r !tring. M#&+% ini ter&iri ata! tiga (agian )ait+ 9a&a (agian 9erta"a O(,e' Pa!$a% )ang ter&iri &ari ti9e0ti9e ;aria(e% &an '#n!tanta< '#n;er!i ;aria(e%< &an "e"(+at '#"entar 9r#gra". Pa&a (agian 'e&+a &i,e%a!'an "engenai #9erat#r &a!ar "ate"ati'a< #9erat#r a'ar &an 9ang'at< #9erat#r e'!9#nen &an %#garit"a< a!i% 9e"(agian &an !i!a a!i% (agi< 4+ng!i trig#n#"etri< 9e"(+%atan (i%angan< 9ena"(aan &an 9eng+rangan (i%angan integer &engan !at+. Pa&a (agian 'etiga &i,e%a!'an "engenai #9erat#r0#9erat#r !tring )ang "e%i9+ti #9erat#r #r& &an $ar< 9an,ang !tring< "engga(+ng'an !tring< #9erat#r +nt+' "en)a%in !tring< &an "en$ari %eta' !tring.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 3!
Modul Pemrograman Komputer
Bagian 1 VARIABEL DAN KONSTANTA
A. Iariabel
Data )ang &ig+na'an &a%a" (aa!a 9e"r#gra"an a'an &i!i"9an &i&a%a" "e"#ri '#"9+ter. Data ter!e(+t (ia!an)a &i!i"9an &a%a" !+at+ ;aria(e% ata+ '#n!tanta. Se(+a ;aria(e% &a%a" (aa!a 9e"r#gra"an ar+! "e"i%i'i ti9e &ata )ang !9e!i4i' !eingga ar+! &i&e4ini!i'an &i aa% 9r#gra" &a%a" (agian &e'%ara!i. Se$ara +"+" ti9e &ata &i'e%#"9#''an "en,a&i 3 (agian (e!ar )ait+ %. 8eks )ait+ (er+9a !e'+"9+%an +r+4 ata+ ang'a (i!a (er+9a 'ata ata+
'a%i"at. Ti9e Te'! ini ter&iri ata! a.Car an)a ter&iri &ari 1 +r+4:ang'a (.String ter&iri &ari (e(era9a +r+4 &an ang'a &. Bilangan )ait+ (er+9a (i%angan )ang ter&iri ata!
a.Integer (i%angan (+%at (.Rea% (i%angan 9e$aan '. Boolean Mer+9a'an ti9e ;aria(e% %#gi'a. Ni%ai &ari ;aria(e% &ari (erti9e
(##%ean a&a%a 8r!e ata+ alse.
Le(i '+!+! &i &a%a" Pa!$a% Laar+! ti9e0ti9e &ata ter!e(+t "e"9+n)ai (e(era9a ;arian< )ang &i(e&a'an #%e rentang &atan)a. Unt+' 9en,e%a!ann)a a'an &i+rai'an 9a&a (agian !e%an,+tn)a
B. on/ersi 8ipe Data
Da%a" Laar+! #(,e'0#(,e' ;i!+a% )ang &i!erta'an )ang &a9at &ig+na'an +nt+' in9+t "a+9+n #+t9+t &ata< !e9erti inp!tbo< edit< listbo &an stringgrid< !e"+an)a (erti9e String. O%e 'arena it+ a9a(i%a 'ita ingin "engg+na'an !+at+ ;aria(e% (erti9e integer ata+ rea% "a'a ar+! &i'#n;er!i &a+%+ "engg+na'an Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 3"
Modul Pemrograman Komputer 9erinta '#n;er!i. Perinta '#n;er!i &a9at &i%a'+'an &i&a%a" 9r#gra" )ang a'an &i,a%an'an< "i!a%n)a &i&a%a" (+tt#n.
8abel % on/ersi Data Dari
e
Perintah
String
Integer
!trt#intob!e)Qstrin"
String
Rea%
!trt#4%#atob!e)Qstrin"
Integer
String
intt#!trob!e)Qinte"er
Rea%
String
4%#att#!trob!e)3real
C#nt# %. Mi!a%'an 'ita a'an "engin9+t !e(+a ;aria(e% )ang (erti9e integer &ari inp!tbo "a'a 9erintan)a a&a%a !e(agai (eri'+t
!trt#intin9+t(#In9+t Data< In9+t'an <
&. Mi!a%'an 'ita a'an "engin9+t'an !e(+a ;aria(e% ) )ang (erti9e rea% &ari
#(,e' edit% "a'a 9erintan)a a&a%a !e(agai (eri'+t
) !trt#4%#ate&it1.tet
'. Se(a%i'n)a "i!a%'an 'ita a'an "ena"9i%'an ;aria(e% )ang (erti9e
integer 'e &a%a" %a(e%1< "a'a 9erintan)a a&a%a !e(agai (eri'+t
%a(e%1.$a9ti#nintt#!tr
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 3#
Modul Pemrograman Komputer C. ,nteger
Integer "er+9a'an ti9e &ata (i%angan (+%at (ai' 9#!iti4 "a+9+n negati4 &a%a" rentang 03*68 ingga 3*6*. Artin)a a9a(i%a 'ita "e"9+n)ai !e(+a ;aria(e% &engan ti9e integer 'e"+&ian &i(eri'an (i%angan &i%+ar rentang ter!e(+t "a'a ;aria(e% ter!e(+t ti&a' a'an "eneri"an)a ata+ a9a(i%a "eneri"a 9+n a'an "enga!i%'an !+at+ ni%ai )ang !a%a. Da%a" ti9e &ata ini !e"+a #9era!i "ate"ati'a (er%a'+ &an &a9at &i g+na'an 9a&a ti9e rea%. Ta(e% (eri'+t "er+9a'an ;arian &ari ti9e &ata integer &engan rentang (ata! (aa &an (ata! ata! !erta +'+ran &a%a" !at+an (it. 8abel & Iarian 8ipe Data ,nteger
8,PE
BatasBa$ah
BatasAtas
8anda
Uk!ran
S#rtint
18
1* P#!iti4:Negati4
80(it
S"a%%int
3*68
3*6* P#!iti4:Negati4
160(it
L#ngint
1*8368
1*836* P#!iti4:Negati4
30(it
Int6
63
631 P#!iti4:Negati4
60(it
B)te
/
55
P#!iti4
80(it
#r&
/
65535
P#!iti4
160(it
L#ng#r&
/
--6*-5
P#!iti4
30(it
Latihan %
Unt+' %e(i "e"aa"i ti9e &ata integer 'ita a'an $#(a "e"(+at !e(+a 9r#gra" proye) +nt+' "engit+ng L+a! &an Ke%i%ing Per!egi Pan,ang< r+"+! )ang &ig+na'an a&a%a !e(agai (eri'+t
L!as ;< P 0 L eliling ;< & 07 P L9
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 4$
Modul Pemrograman Komputer Beri'+t &e!ain 4#r" &i Laar+!
Te"9at'an '#"9#nen0'#"9#nen (eri'+t 9a&a 4#r" 'e"+&ian +(a ni%ai 9r#9ertie!0n)a
8abel ' Properties Beserta Ial!e dari omponen omponen
Properties
Ial!e
La(e%1
Ca9ti#n
Pan,ang
La(e%
Ca9ti#n
Le(ar
La(e%3
Ca9ti#n
L+a!
La(e%
Ca9ti#n
Ke%i%ing
E&it1
Tet
E&it
Tet
E&it3
Tet
E&it B+tt#n1
Tet Ca9ti#n
Hit+ng
Sete%a '#"9#nen &i!et 9r#9ertie!n)a !e9erti 9a&a Ta( e% K%i' D+a Ka%i 9a&a '#"9#nen B+tt#n &an "a!+''an '#&e !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 41
Modul Pemrograman Komputer
A9a(i%a 9r#gra" &i,a%an'an &engan "e"i%i "en+
r!n ata+ "ene'an a'an
ta"9a' a!i% !e(agai (eri'+t
D. :eal
Rea% "er+9a'an (i%angan 9e$aan. Ti9e (i%angan ini (ia!an)a &a9at "eng+'+r !e!+at+ &engan (i%angan )ang !angat 'e$i% ingga (i%angan )ang !angat (e!ar (ai' 9#!iti4 "a+9+n negati4. Rentang +nt+' ti9e rea% a&a%a .- 1/ 03- ingga 1.*
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 42
Modul Pemrograman Komputer 1/38 +nt+' (i%angan 9#!iti4 &an negati4. Tent+n)a ti9e rea% ini &a9at "e"en+i !e"+a #9era!i "ate"ati'a &an &a9at &iga(+ng'an &engan ti9e integer. Ta(e% (eri'+t "er+9a'an ;arian &ari ti9e rea% &engan rentang (ata! (aa &an (ata! ata!. 8abel * Iarian 8ipe Data :eal 8,PE
BatasBa$ah
BatasAtas
8anda
Rea%
1/ .
03-
1.* 1/38 P#!iti4:Negati4
Sing%e
1.5 1/
05
3. 1/38 P#!iti4:Negati4
D#+(%e
5./ 1/
03
1.* 1/3/8 P#!iti4:Negati4
3.1/
0-3
1.1 1/-3 P#!iti4:Negati4
63J1
631 P#!iti4:Negati4
-33*/3685**.58/8
-33*/3685**.58/* P#!iti4:Negati4
Eten&e& C#"9 C+rren$)
Da%a" Pa!$a% "et#&e 9erit+ngan ti9e rea% a&a &+a ,eni! )ait+ &engan "eng+na'an so#t(are &an co1processor. Perit+ngan "engg+na'an co1processor a'an %e(i $e9at.
Latihan &
Kita a'an (er%ati &engan ti9e &ata rea% &engan "e"(+at !e(+a 9r#gra" pro!e) +nt+' "engit+ng L+a! &an 'e%i%ing Ling'aran. R+"+! )ang &ig+na'an a&a%a !e(agai (eri'+t
L!as ;< pi0 :0: eliling ;< &0pi0:
&engan 9i3.1 a&a%a !e(+a '#n!tant a &a%a" Pa!$a% Laar+!. De!ain F#r" a&a%a !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 43
Modul Pemrograman Komputer
Te"9at'an '#"9#nen0'#"9#nen (eri'+t 9a&a 4#r" 'e"+&ian +(a ni%ai 9r#9ertie!0n)a
8abel G Properties Beserta Ial!e dari omponen omponen
Properties
Ial!e
F#r"
Ca9ti#n
L+a!&anKe%i%ingLing'aran
La(e%1
Ca9ti#n
Mengit+ng L+a! &an Ke%i%ing Ling'aran
La(e%
Ca9ti#n
7ari0,ari
La(e%3
Ca9ti#n
L+a!
La(e%
Ca9ti#n
Ke%i%ing
E&it1
Tet
E&it
Tet
E&it3
Tet
B+tt#n1
Ca9ti#n
Hit+ngXX
Sete%a '#"9#nen &i!et 9r#9ertie!n)a !e9erti 9a&a Ta( e% 5 K%i' D+a Ka%i 9a&a '#"9#nen B+tt#n &an "a!+''an '#&e !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 44
Modul Pemrograman Komputer
A9a(i%a 9r#gra" &i,a%an'an &engan "e"i%i "en+
r!n ata+ "ene'an a'an
ta"9a' a!i% !e(agai (eri'+t
Kita &a9at "engat+r 9r#9erti )ang %ain agar ta"9i%ann)a "en,a&i %e(i "enari'< "i!a%n)a "eng+(a (ent+' &an arna 4#nt !e9erti 9a&a $#nt# &iata!.
E. (tring
String a&a%a ti9e )ang na) ter&iri &ari '+"9+%an +r+4< a9a(i%a &i(eri'an !e(+a ang'a "a'a 9a&a ti9e ini ang'a ter!e (+t a'an &i9er%a%+'an !e(agai '+"9+%an
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 45
Modul Pemrograman Komputer +r+4. Pa&a ti9e String 'ita ti&a' (i!a "e%a'+'an #9era!i "ate"ati'a. Pan,ang &ari ti9e String ini &a9at &i&e4ini!i'an &engan "ena"(a'an tan&a '+r+ng !i'+ !ete%a 'ata !tring 9a&a (agian &e'%ara !i. I!i &ari '+r+ng !i'+ ter!e(+t ar+! (er+9a (i%angan (+%at 9#!iti4. 8abel @ Iarian 8ipe Data (tring 8ipe
Pan#ang
Car
1 $ara$ter
S#rtString
55 $ara$ter!
An!iString
Y31 $ara$ter!
i&eString
Y3/ $ara$ter!
Se$ara '+!+! ti9e Car ti&a' &a9at &iga(+ng'an &engan ti9e !tring %ainn)a< !e&ang'an ti9e !tring !e%ain $ar &a9at &iga(+ng'an &engan ti9e !tring %ainn)a.
Latihan '
Kita a'an "e"(+at !+at+ 9r#gra" +nt+' "enan)a'an N#"#r Pe%anggan< Na"a Pe%anggan< !erta A%a"at Pe%anggan. Da%a" a% ini !e"+a ;aria(e% (erti9e !tring 'arena ti&a' a'an &i%a'+'an #9era!i "ate"ati'a tera&a9 ;aria(e%n)a.
Ke"+&ian at+r 9r#9ertie! &ari !etia9 #(,e' &engan "engi'+ti 9et+n,+' 9a&a Ta(e% *< tent+n)a (i!a &ita"(a'an &engan "engat+r 9r#9erti %ain agar ta"9i%ann)a %e(i "enari'.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 4
Modul Pemrograman Komputer
8abel F Properties Beserta Ial!e dari omponen omponen
Properties
Ial!e
F#r"
Ca9ti#n
Pe%anggan
La(e%1
Ca9ti#n
DataPe%anggan
La(e% La(e%3
Ca9ti#n Ca9ti#n
N#"#r Na"a
La(e%
Ca9ti#n
A%a"at
E&it1
Tet
E&it
Tet
E&it3
Tet
B+tt#n1
Ca9ti#n
Ta"9i%'an
Ke"+&ian '%i' &+a 'a%i 9a&a (+tt#n1 &an "a!+''an '#&e !e(agai (eri'+t
7a%an'an 9r#gra" &engan "e"i%i "en+ r+n ata+ "ene'an F-
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 4!
Modul Pemrograman Komputer
A9a(i%a 'ita "ene'an t#"(#% ta"9i%'an a'an "+n$+% ,en&e%a &ia%#g !e(agai (eri'+t
. omentar Program
K#"entar a&a%a (agian 9r#gra" )ang ti&a' a'an &i(a$a &ie'!e'+!i. T+,+an &ari '#"entar a&a%a "e"(eri 'eterangan 9a&a 9r#gra" ata+ (agian &ari 9r#gra" !eingga a9a(i%a a&a (agian 9r#gra" )ang err#r &a9at !egera &i'eta+i (agian )ang "ana.
Se$ara +"+" a&a &+a $ara +nt+' "e"(+at '#"entar 9r#gra" %. A9a(i%a '#"entar )ang &ig+na'an an)a !at+ (ari! "a'a &ig+na'an tan&a
:: &i &e9an '#"entarn)a &. A9a(i%a '#e"entar )ang &ig+na'an %e(i &ari !at+ (ari! "a'a '#"entar
ter!e(+t &iaa%i &engan Z &an &ia'iri &engan [.
C#nt# Pa&a 9r#gra" !e(e%+"n)a "engenai "engit+ng %+a! &an 'e%i%ing %ing'aran a'an &ita"(a'an 'eterangan "engg+na'an 'e&+a $ara &iata!. Pa&a aa% 9r#gra" &ita"(a'an '#"entar "engenai 9r#gra" )ang &i(+at )ait+ 'a%i"at (eri'+t Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 4"
Modul Pemrograman Komputer
ZPa&a 9r#gra" ini a'an &i ,e%a!'an $ara "engit+ng L+a! &an 'e%i%ing Ling'aran &engan In9+t ,ari0,ari %ing'aran O+t9+t L+a! &an Ke%i%ing %ing'aran[
Pa&a '#"entar ter!e(+t ter&iri &ari %e(i &ari !at+ (ari! !eingga "engg+na'an tan&a Z ... [. Pa&a !etia9 (agian 9r#gra" &ita"(a'an 'a%i"at 9en&e' (eri!i 'eterangan "engenai (agian 9r#gra" )ait+ ::in9+t &ata ,ari,ari ::"engit+ng %+a! &an 'e%i%ing %ing'aran ::"ena"9i%'an a!i%
Pa&a 'etiga '#"entar ter!e(+t an)a ter&iri &ari !at+ (ari! !eingga "engg+na'an tan&a ::. Perati'an a!i%n)a 9a&a ga"(ar &i(aa ini
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 4#
Modul Pemrograman Komputer K. onstanta
K#n!tanta a&a%a !+at+ arga )ang ni%ain)a teta9 ata+ ta' &a9at (er+(a. K#n!tanta %e(i (an)a' &ig+na'an &a%a" 9erit+ngan Ki"ia< Fi!i'a &an Mate"ati'a. Mi!a%n)a '#n!tanta 9i< (i%angan a;#ga&r#< 'e$e9atan $aa)a< 'e$e9atan !+ara &an %ain0%ain. Be(era9a '#n!tanta te%a &i!erta'an &i&a%a" (aa!a Pa!$a% Laar+! !eingga ti&a' 9er%+ &i&e'%ara!i'an %agi< "i!a%n)a '#n!tanta pi \ )ang (erni%ai 3.115- !e9erti )ang te%a &ig+na'an 9a&a Latian "engenai "engit+ng L+a! &an Ke%i%ing Ling'aran.
Latihan *
Pa&a %atian 'a%i ini a'an &i(+at !e(+a 9r#gra" +nt+' "engit+ng energi (er&a!ar'an r+"+! ein!tein. B+at%a F#r" &engan &e!ain !e(agai (eri'+t
Ke"+&ian at+r 9r#9ertie!n)a !e(agai (eri'+t 8abel > Properties Beserta Ial!e dari omponen omponen
Properties
Ial!e
La(e%1
Ca9ti#n
Ma!!a
La(e% B+tt#n1
Ca9ti#n Ca9ti#n
Energi Hit+ng
Ke"+&ian K%i' &+a 'a%i 9a&a (+tt#n1 &an "a!+''an '#&e (eri'+t ini
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 5$
Modul Pemrograman Komputer
7a%an'an &engan "ene'an t#"(#% r+nning ata+ te'an F- !eingga a'an "+n$+% 9r#gra" (eri'+t ini
H. (oal)soal %. B+at%a !e(+a 9r#gra" +nt+' "engit+ng =#%+"e &an L+a! 9er"+'aan
Ba%#' &engan r+"+! !e(agai (eri'+t =#%+"e P L T L+a! Per"+'aan P L J P T J L T &engan P Pan,ang< L Le(ar &an T Tinggi Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 51
Modul Pemrograman Komputer &. B+at%a !e(+a 9r#gra" +nt+' "engit+ng =#%+"e &an L+a! 9er"+'aan
B#%a &engan r+"+! !e(agai (eri'+t =#%+"e :3 9i R R R L+a! Per"+'aan 9i R R &engan R ,ari0,ari
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 52
Modul Pemrograman Komputer
Bagian 2 OPERASI MATEMATIKA
A. "perator Dasar -atematika
Se$ara +"+" #9erat#r0#9erat#r &a!ar &a%a" "ate"ati'a )ait+ 9en,+"%aan J< 9eng+rangan 0< 9er'a%ian &an 9e"(agian : &a9at &ig+na'an &i &a%a" Laar+!. Be(era9a a% )ang 9er%+ &i9erati'an &a%a" "e%a'+'an #9era!i "ate"ati'a &a%a" (aa!a 9e"r#gra"an Laar+! a&a%a !e(agai (eri'+t %. Tan&a !a"a &engan )ang &ig+na'an a&a%a ;< &. =aria(e% )ang "ena"9+ng a!i% #9era!i "ate"ati'a ar+! (era&a
&i!e(e%a 'iri ;< '. O9era!i "ate"ati'a ar+! "engi'+ti ting'atan #9era!i "ate"ati'a &an
&i%eta''an &i !e(e%a 'anan tan&a ;< *. Pa&a !etia9 9er!a"aan #9era!i "ate"ati'a an)a (#%e a&a !at+ tan&a ;< G. Setia9 'a%i"at ar+! &ia'iri &engan tan&a titi' '#"a O6O
Ting'atan0ting'atan &a%a" #9era!i "ate"ati'a a&a%a +r+tan #9era!i "ana )ang &i%a'!ana'an ter%e(i &a+%+. Ting'atan0ting'atan ini !e$ara +"+" (er%a'+ &a%a" (aa!a 9e"r#gra"an Pa!$a% Laar+!. A&a9+n at+ran &a%a" ting'atan0ting'atan #9era!i "ate"ati'a ter!e(+t a&a%a %. O9era!i &i%a'!ana'an &ari 'iri 'e 'anan &. Ting'atan 9erta"a a&a%a !e"+a #9era!i )ang (era&a &a%a" tan&a '+r+ng
... '. Ting'atan 'e&+a a&a%a #9era!i 9ang'at &an a'ar *. Ting'atan 'etiga a&a%a #9era!i 9er'a%ian &an 9e"(agian G. Ting'atan 'ee"9at a&a%a #9era!i 9en,+"%aan &an 9er'a%ian
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 53
Modul Pemrograman Komputer B. !ngsi (Q: dan (Q:8
T+r(# Pa!$a% Laar+! "en)e&ia'an !+at+ 4+ng!i +nt+' "engit+ng '+a&rat )ait+ (Q: &an a'ar '+a& rat )ai t+ (Q:8. F+ng!i (Q: &a9at &ig+na'an #%e ;aria(e% ata+ '#n!tanta )ang (erti9e rea% ata+ integer (ai' 9#!iti4 "a+9+n negati4< &engan ti9e a!i%n)a !e!+ai &engan ti9e arg+"en. Se"entara 4+ng!i (Q:8 &a9at &ig+na'an ;aria(e% ata+ '#n!tanta )ang (erti9e rea% ata+ integer )ang an)a (erni%ai 9#!iti4< &an a!i%n)a ar+! (erti9e rea%. C#nt# a !r5 ( !rt16
a'an "enga!i%'an a 5 a'an "enga!i%'an (
$ !r0*
a'an "enga!i%'an $ -
& !rt06
a'an "enga!i%'an err#r 'arena ni%ai )ang &ia'ar'an negati4
Latihan %
Kita a'an "e"(+at 9r#gra" +nt+' "en$ari !i!i "iring $ &ari r+"+! P)tag#ra! a] J (] $]. Unt+' it+ a'an &ig+na'an 4+ng !i S>R &an S>R T. B+at%a !e(+a 4#r" &engan &e!ain !e9erti (eri'+t
Ke"+&ian at+r 9r#9ertin)a !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 54
Modul Pemrograman Komputer
8abel % Properties Beserta Ial!e dari omponen omponen
Properties
Ial!e
La(e%1
Ca9ti#n
Si!iBaaa
La(e%
Ca9ti#n
Si!iTega'(
La(e%
Ca9ti#n
Si!iMiring$
E&it1
Tet
E&it1
Tet
E&it1
Tet
B+tt#n1
Ca9ti#n
Hit+ng
Ke"+&ian '%i' &+a 'a%i 9a&a (+tt#n &an "a!+''an '#&e (eri'+t ini proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar
a1b1c ; real6
begin inp!t data a;
Sete%a &i e'!e'+!i &engan "ene'an t#"(#% r+n ata+ F- "a'a a!i%n)a a&a%a !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 55
Modul Pemrograman Komputer
C. !ngsi ESP dan LN
E'!9#nen )ang "er+9a'an 9er9ang'atan &engan (i%angan &a!ar e &i&a%a" Pa!$a% Laar+! &it+%i!'an !e(agai ESP. Se&ang'an L#garit"a nat+ra% )ait+ %#garit"a &engan (i%angan &a!ar e &i &a%a" (aa!a 9e"r#gra"an Pa!$a% Laar+! &it+%i!'an !e(agai LN. C#nt# a E9 ( Ln 3/
F+ng!i ESP &an LN a'an "enga!i%'an (i%angan rii% !eingga ;aria(e% a!i% a &an ( &a%a" $#nt# &iata ! ar+! (erti9e rea%. Unt+' 4+ng!i LN< (i%angan )ang (era&a &a%a" tan&a '+r+ng ar+! %e(i (e!ar &ari /.
Latihan &
Unt+' (er%ati 9engg+naan 4+ng!i E?P &an LN 'ita 'an "e"(+at 9r#gra" +nt+' "engit+ng )< &engan &an ) &iin9+t'an. Perati'an 9er!a"aan "ate"ati'a (eri'+t ini 4
y
= e %n( 5 )
y
e) %n Mengg+na'an 9er!a"aan ter!e(+t "a'a 'ita &a9at "e"(+at 9r#gra"n)a &engan &e!ain !e(agai (eri'+t Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 5
Modul Pemrograman Komputer
Ke"+&ian at+r 9r#9ertin)a !e(agai (eri'+t 8abel & Properties Beserta Ial!e dari omponen omponen
Properties
Ial!e
La(e%1
Ca9ti#n
?
La(e%
Ca9ti#n
@
La(e%3
Ca9ti#n
?Pang'at@
E&it1
Tet
E&it
Tet
E&it3
Tet
B+tt#n1
Ca9ti#n
Hit+ng
Ke"+&ian '%i' &+a 'a%i 9a&a (+tt#n &an "a!+''an '#&e (eri'+t ini
proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar
1y1 Pangkaty ; real6
begin inp!t data ;
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 5!
Modul Pemrograman Komputer perhit!ngan Pangkaty;
Sete%a &ie'!e'+!i a'an 'e%+ar a!i% !e(agai (eri'+t
D. !ngsi 8rigonometri
Da%a" t+r(# 9a!$a%< 4+ng!i trig#n#"etri )ang &i!e&ia'an an)a SIN< COS &an ARCTAN. Arg+"en SIN &an COS ter!e(+t &a%a" !at+an ra&ian )ang "enga!i%'an !+at+ (i%angan rea%< !e&ang'an arg+"en ARCTAN a&a%a !e(+a (i%angan rea% )ang "enga!i%'an !+&+t &a%a" !at+an ra&ian.
Latihan '
Da%a" %atian 'a%i ini 'ita a'an "e"(+at !+at+ 9r#gra" +nt+' "engit+ng !in+!< $#!in+! &an tangen &ari !+at+ !+&+t. A&a9+n 'etent+ann)a a&a%a !e(agai (eri'+t Tan a !in a $#! a Unt+' it+ (+at%a !e(+a 4#r" &engan &e!ain !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 5"
Modul Pemrograman Komputer
Ke"+&ian at+r 9r#9ertie! !e(agai (eri'+t 8abel ' Properties Beserta Ial!e dari omponen omponen
Properties
Ial!e
La(e%1
Ca9ti#n
S+&+t
La(e%
Ca9ti#n
Sin+!
La(e%3
Ca9ti#n
C#!in+!
La(e%
Ca9ti#n
Tangen
E&it1
Tet
E&it
Tet
E&it3
Tet
E&it
Tet
B+tt#n1
Ca9ti#n
Hit+ng
Ke"+&ian '%i' &+a 'a%i 9a&a (+tt#n &an "a!+''an '#&e (eri'+t ini proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar 1 sin1 cos1 tan ; real6 begin inp!t s!d!t ;
=0pi96 Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 5#
Modul Pemrograman Komputer cos;=0pi96 tan;
Sete%a &ie'!e'+!i a'an 'e%+ar a!i% !e(agai (eri'+t
E. "perator -"D dan D,I
O9erat#r M#& &ig+na'an +nt+' "en&a9at'an !i!a &ari a!i% 9e"(agian &an #9erat#r Di; +nt+' "e"9er#%e a!i% (+%at 9e"(agian.
Latihan *
Da%a" %atian 'a%i ini 'ita a'an "e"(+at 9r#gra" +nt+' "engit+ng a!i% (agi &an !i!a a!i% (agi. B+at%a !e(+a 4#r" &engan &e!ain !e9erti (eri'+t ini
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal $
Modul Pemrograman Komputer
Ke"+&ian at+r 9r#9ertie! !e(agai (eri'+t 8abel * Properties Beserta Ial!e dari omponen omponen
Properties
Ial!e
La(e%1
Ca9ti#n
Pen)e(+t
La(e%
Ca9ti#n
Pe"(i%ang
La(e%3
Ca9ti#n
Ha!i%Bagi
La(e%
Ca9ti#n
Si!a
E&it1
Tet
E&it
Tet
E&it3
Tet
E&it
Tet
B+tt#n1
Ca9ti#n
Pe"(agian
Ke"+&ian '%i' &+a 'a%i 9a&a (+tt#n &an "a!+''an '#&e (eri'+t ini proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar 1 y1 hasil1 sisa ; integer6 begin inp!t s!d!t ;
Hal 1
Modul Pemrograman Komputer perhit!ngan hasil;< di/ y6 sisa;< mod y6 o!tp!t edit'.tet;
Sete%a &ie'!e'+!i a'an 'e%+ar a!i% !e(agai (eri'+t
. !ngsi, 8:UNC dan :AC
F+ng!i TRUNC &i9a'ai +nt+' "enga!i%'an (i%angan (+%at &engan $ara "e"(+ang (agian &e!i"a% !+at+ (i%angan rea%. Se&ang'an 4+ng!i FRAC +nt+' "enga"(i% (agian &e!i"a%n)a.
Latihan G
Unt+' %e(i "e"aa"i 4+ng!i Tr+n$ &an Fra$ (+at%a !e(+a 4#r" &engan &e!ain !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 2
Modul Pemrograman Komputer
Ke"+&ian at+r 9r#9ertie! !e(agai (eri'+t 8abel G Properties Beserta Ial!e dari omponen omponen
Properties
Ial!e
La(e%1
Ca9ti#n
Bi%angan
La(e%
Ca9ti#n
DiDe9anK#"a
La(e%3
Ca9ti#n
De!i"a%
E&it1
Tet
E&it
Tet
E&it3 B+tt#n1
Tet Ca9ti#n
Pe"i!aan
Ke"+&ian '%i' &+a 'a%i 9a&a (+tt#n &an "a!+''an '#&e (eri'+t ini proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar 1desimal ; real6 depan ; integer6 begin inp!t bilangan pecahan ;
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 3
Modul Pemrograman Komputer o!tp!t edit&.tet;
Sete%a &ie'!e'+!i a'an 'e%+ar a!i% !e(agai (eri'+t
K. !ngsi :"UND
F+ng!i ROUND "e"(+%at'an !e(+a (i%angan rea% 'e (i%angan (+%at )ang ter&e'at. F+ng!i ROUND (er%a'+ +nt+' at+ran 9e"(+%atan (i%angan !e(agai (eri'+t %. 7i'a ang'a &i (e%a'ang '#"a '+rang &ari 5 "a'a ang'a &i &e9an '#"a
teta9 &. 7i'a ang'a &i (e%a'ang '#"a %e(i &ari 5 "a'a ang'a &i &e9an '#"a
&ita"(a'an &engan !at+ '. 7i'a ang'a &i (e%a'ang '#"a !a"a &engan %i"a "a'a ang'a &i &e9an
'#"a
◦ teta9 a9a(i%a ang'a ter!e(+t gena9 ◦ &ita"(a'an &engan !at+ a9a(i%a ang'a ter!e(+t gan,i%
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 4
Modul Pemrograman Komputer Latihan @
Unt+' %e(i "e"aa"i 4+ng!i r#+n& 'ita a'an "e"(+at !+at+ 9r#gra" !e&erana &engan &e!ain !e(agai (eri'+t
Ke"+&ian at+r 9r#9ertie! !e(agai (eri'+t 8abel G Properties Beserta Ial!e dari omponen omponen
Properties
Ial!e
La(e%1
Ca9ti#n
Bi%angan
La(e% E&it1
Ca9ti#n Tet
Ha!i%Pe"(+%atan
E&it
Tet
B+tt#n1
Ca9ti#n
Pe"(+%atan
Ke"+&ian '%i' &+a 'a%i 9a&a (+tt#n &an "a!+''an '#&e (eri'+t ini proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar ; real6 b!lat ; integer6 begin inp!t bilangan pecahan ;
Hal 5
Modul Pemrograman Komputer o!tp!t edit&.tet;
Sete%a &ie'!e'+!i a'an 'e%+ar a!i% !e(agai (eri'+t
H. Penambahan dan Peng!rangan dengan sat!
Se(+a 9r#gra" (ia!an)a &ite"+'an !+at+ 9ern)ataan 9ena"(aan ata+ 9eng+rangan (i%angan integer &engan !at+ !e$ara (er+%ang0+%ang. Pr#!e! !e9erti ini a9a(i%a &ig+na'an #9era!i "ate"ati'a !e9erti (eri'+t ini
aaJ1 ((01
a'an "e"a'an "e"#ri )ang $+'+9 (e!ar !eingga 9r#gra" a'an (er,a%an %a"(at. Unt+' "engata!i a% ter!e(+t Pa!$a% Laar+! "en)e&ia'an !+at+ 4+ng!i +nt+' "ena"(a'an ata+ "eng+rang'an (i%angan &engan !at+ )ait+ #9erat#r In$ &an De$.
in$a
(erarti ;aria(e% a &ita"(a'an &engan !at+
&e$(
(erarti ;aria(e% ( &i'+rang'an &engan !at+
Pengg+naan #9erat#r ini nantin)a a'an (an)a' &i%a'+'an &a%a" (agian 9eng+%angan loopin".
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal
Modul Pemrograman Komputer ,. (oal)soal %. S+at+ 9er+!aaan "engga,i 'ar)aann)a tergant+ng &ari Ga,i P#'#'<
T+n,angan< !erta U9a %e"(+r. T+n,angan &i(eri'an !e(e!ar /^ &ari ga,i 9#'#'< %e"(+r 9er,a" 1.5^ &ari ga,i 9#'#'. B+at 9r#gra" ga,i )ang &iteri"a 'ar)aan 9er+!aaan ter!e(+t.
O+t9+t )ang &iara9a'an NAMA
NIP
GA7IPOKOK
7ML7AMLEMBUR
UPAHLEMBUR
TUN7ANGAN
GA7I @ANG DITERIMA
R9
Petun!u) 6 7una)an )omponen memo untu) menampil)an output.
&. B+at 9r#gra" +nt+' "en$ari ;#%+"e ta(+ng &an %+a! !e%i"+t ta(+ng<
&engan ,ari0,ari &an tinggi &iin9+t'an. R+"+! +nt+' ta(+ng L+a! !e%i"+t ta(+ng
'e%i%ing a%a!tinggi
=#%+"eta(+ng
% +a! a%a!tinggi
'. 7ari0,ari (+"i !e'itar 63*/ '". B+at 9r#gra" +nt+' "engit+ng ;#%+"e<
%+a! !erta 'e%i%ing (+"i< (i%a Ke%i%ing
\r
=#%+"e
\r_
L+a!
:3r_
Petun!u) 6 7una)an #un"si $8%
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal !
Modul Pemrograman Komputer *. B+at%a !e(+a 9r#gra" +nt+' "enent+'an +'+ran !a"9e% +nt+' "ena'!ir
&engan in9+t a&a%a 9r#9#r!i 9< (#+n& #4 err#r B &an N. R+"+! +'+ran !a"9e% a&a%a !e(agai (eri'+t n=
n/ n /− 1 &engan 1+ 9
(
n /=
√ ( p ( 1− p )) B
)
Petun!u)6 u)uran sampel n selalu dibulat)an )eatas.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal "
Modul Pemrograman Komputer
Bagian 3 OPERASI KARAKTER DAN STRING
Se$ara +"+" 'ara'ter &an !tring 'e&+an)a "er+9a'an ti9e )ang "e"+at +r+4 9er(e&aann)a a&a%a ti9e 'ara'ter $ar an)a "e"+at !at+ +r+4 !a,a !e&ang'an ti9e !tring (i!a "e"+at ingga 55 'ara'ter. Dengan &e"i'ian 'ita &a9at "en&e4ini!i'an 'ara'ter "e%a%+i ti9e !tring &engan $ara "enga"(i% !e(+a +r+4 'ara'ter &ari !tring ter!e(+t. Tan&a '+r+ng !i'+ ... &ia'ir ;aria(e% !tring "er+9a'an $ara "enga"(i% !e(+a 'ara'ter &ari ;aria(e% !tring &engan "engi!i ang'a &i &a%a" '+r+ng !i'+ ter!e(+t. Mi!a%'an 'ita "e"9+n)ai ;aria(e% !tring na"a )ang (eri!i %aar+!< a9a(i%a 'ita a'an "enga"(i% +r+4 9a&a ;ari(e% na"a "a'a 'ita t+%i!'an +r+4na"a3 !eingga ;arie(e% +r+4 (erni%ai .
A. !ngsi ":D dan CH:
Se"+a +r+4 &i&a%a" Pa!$a% Laar+! &a9at &i'#&e'an &engan !+at+ (i%angan< (i%angan it+ &i!e(+t (i%angan ASCII. Setia9 +r+4:'ara'ter "e"9+n)ai (i%angan ASCII )ang (er(e&a0(e&a ter"a!+' +r+4 (e!ar &an +r+4 'e$i%< "i!a%n)a (i%angan ASCII +nt+' +r+4 a (er(e&a &engan (i%angan ASCII +nt+' +r+4 A. F+ng!i ORD a'an "enga!i%'an '#&e !+at+ 'ara'ter 9a&a ta(e% ASCII. Se(a%i'n)a 4+ng!i CHR a'an "enga!i%'an 'ara'ter ASCII &ari !+at+ (i%angan.
Latihan %
Kita a'an "e"(+at !+at+ 9r#gra" +nt+' "ena"9i%'an '#&e ASCII &ari !+at+ 'ara'ter &an "ena"9i%'an !+at+ 'ara'ter &ari !e(+a (i%angan ASCII. B+at%a !e(+a F#r" &engan &e!ain !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal #
Modul Pemrograman Komputer
At+r 9r#9ertin)a !e9erti 9a&a ta(e% (eri'+t ini 8abel % Properties Beserta Ial!e dari omponen omponen
Properties
Ial!e
La(e%1
Ca9ti#n
Kara'ter
La(e%
Ca9ti#n
Bi%angan
E&it1
Tet
E&it
Tet
E&it3
Tet
E&it
Tet
B+tt#n1
Ca9ti#n
ORD
B+tt#n
Ca9ti#n
CHR
Ke"+&ian '%i' &+a 'a%i 9a&a (+tt#n &an "a!+''an '#&e (eri'+t ini proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar h!r!f ; string6 kar ;char6 hasil;byte6 begin h!r!f;
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal !$
Modul Pemrograman Komputer end6
proced!re 8orm%.B!tton&Click7(ender; 8"b#ect96 /ar angka ;byte6 hasil ; string6 begin angka;
Sete%a &ie'!e'+!i a'an 'e%+ar a!i% !e(agai (eri'+t
B. !ngsi UPCA(E
F+ng!i UPCASE a'an "enga!i%'an +r+4 (e!ar &ari !+at+ a(,a&. F+ng!i ini an)a a'an "e"9+n)ai arti a9a(i%a &atan)a +r+4 'e$i%. C#nt# !pcase7Ola+ar!sO9 a'an "e"(eri'an a!i% LA2ARUS !pcase7OLATar!sO9 a'an "e"(eri'an a!i% LA2ARUS !pcase7Ola+a:U(O9 a'an "e"(eri'an a!i% LA2ARUS !pcase7OLATA:U(O9 a'an "e"(eri'an a!i% LA2ARUS
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal !1
Modul Pemrograman Komputer
C. !ngsi LENK8H
Pan,ang !e(+a !tring &a9at &i&e4ini!'an &i&a%a" Pa!$a% Laar+! "engg+na'an 4+ng!i LENGTH. F+ng!i LENGTH &ig+na'an +nt+' "engit+ng (an)a'n)a 'ara'ter )ang a&a 9a&a !e(+a !tring< 'ara'ter )ang &iit+ng ter"a!+' tan&a (a$a ang'a &an !9a!i. Ha!i% &ari 4+ng!i LENGTH (erti9e integer.
C#nt# length7Oband!ngO9 akan menghasilkan nilai F length7Oota Band!ngO9 akan menghasilkan nilai %& kata%;
D. !ngsi C"PM
Men&+9%i'at !+at+ 'ata ata+ 'a%i"at &a%a" !+at+ !tring 'a&ang &i(+t+'an ter+ta"a &a%a" "e"(+at !+at+ '+"en. Baa!a Pa!$a% "en)e&ia'an 4+ng!i COP@ +nt+' "enangani a% ter!e(+t. F+ng!i COP@ a&a%a 4+ng!i )ang "enga"(i% !e(agian !tring &ari !+at+ !tring. C#nt# kata%;
Nilai dari hasil adalah OpemrogramanO. arena angka F men!n#!kkan karakter pertama yang akan dicopy dan angka %% men!n#!kkan banyak karakter yang dicopy setelah karakter ke F.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal !2
Modul Pemrograman Komputer E1 !ngsi P"(
Da%a" 9en+%i!an '+"e n a&a'a%an)a 'ita ingin "ene"+'an 9#!i!i !e(+a 'ata &ari !+at+ '+"en. Baa!a Pa!$a% Laar+! "en)e&ia'an !e(+a 4+ng!i +nt+' "enangani a% ter!e(+t )ait+ 4+ng!i POS. F+ng!i POS a&a%a 4+ng!i +nt+' "enent+'an %eta' !e(+a !tring 9a&a !tring )ang %ain. Bi%a !tring )ang &i%a$a' ti&a' &i'ete"+'an< "a'a ni%ain)a a&a%a / n#%. C#nt# kata%;
Nilai dari hasil adalah * karena kata OasaO berada di posisi karakter ke *.
. !ngsi C"NCA8
Unt+' "engga(+ng'an (e(era9a !tring &i &a%a" Pa!$a% Laar+! &a9at "engg+na'an 4+ng!i CONCAT. C#nt# kata%;
Nilai dari hasil adalah O,DE La+ar!sO
K. Prosed!r ":-A8
Se(+a ;aria(e% rea% )ang &ita"9i%'an 9a&a !+at+ #+t9+t (er+9a tet ata+ %a(e% "engan&+ng (an)a' ang'a &i(e%a'ang '#"a !e!+ai &engan (an)a'n)a a!i% 9erit+ngan. Ter'a&ang 'ita ti&a' "e"(+t+'an ang'a ter%a%+ (an)a'< "i!a%n)a
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal !3
Modul Pemrograman Komputer !a,a 'ita an)a ingin "ena"9i%'an ang'a &i(e%a'ang '#"a. Unt+' it+ &a%a" Pa!$a% Laar+! &ig+na'an 9r#!e&+r FORMAT.
Latihan &
Da%a" %tian 'a%i ini 'ita a'an "e"(+at 9r#gra" +nt+' "ena"9i%'an (i%angan rea% &engan an)a &+a ang'a &i(e%a'ang '#"a. B+at%a !e(+a 4#r" &engan &e!ain !e(agai (eri'+t
'e"+&ian at+r 9r#9ertin)a !e9erti 9a&a ta(e% &i(aa ini 8abel & Properties Beserta Ial!e dari omponen omponen
Properties
Ial!e
La(e%1
Ca9ti#n
Bi%angan
E&it1
Tet
E&it
Tet
B+tt#n1
Ca9ti#n
FORMAT
Ke"+&ian '%i' &+a 'a%i 9a&a (+tt#n &an "a!+''an '#&e (eri'+t ini proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar hasil ; real6 begin hasil;
Hal !4
Modul Pemrograman Komputer end6
Sete%a &ie'!e'+!i a'an 'e%+ar a!i% !e(agai (eri'+t
H. (oal)soal %. B+at%a !e(+a 9r#gra" +nt+' "e"+tar 'a%i"at Baa!a Pe"r#gra"an
Laar+! "en,a&i Laar+! Baa!a Pe"r#gra"a n "engg+na'an #9era!i !tring. &. B+at%a !e(+a 9r#gra" +nt+' "ene"+'an !e(+a 'ata )ang &iin9+t'an
&ari 'a%i"at (eri'+t Sa)a !e&ang (e%a,ar Baa!a Pe"r#gra"an Laar+!. Baa!a Pe"r#gra"an Laar+! (er(a!i!'an 9a&a 4ree Pa!$a% )ang (er%i!en!i grati!. '. Sa%in 'a%i"at Baa! a Pe"r#gra"an Laar+! 9a&a !#a% n#"#r &an
!i"9an a!i%n)a &i !e(+a ;aria(e%< 'e"+&ian +(a "en,a&i +r+4 (e!ar.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal !5
Modul Pemrograman Komputer
MODUL 3 STRUKTUR KONDISI
PENDAHULUAN
Da%a" "#&+% ini a'an &i9e%a,ari "engenai Str+'t+r '#n&i!i &ari !+at+ 9r#gra" )ang ter&iri ata! &+a (agian )ait+ !tr+'t+r '#n&i!i I4..Ten &an !tr+'t+r '#n&i!i Ca!e..#4. M#&+% ini ter&iri ata! &+a (agian )ait+ !tr+'t+r '#n&i!i I4..ten )ang "e%i9+ ti '#n&i!i i4..ten< i4..ten.. e%!e< '#n&i!i %e(i &ari !at+< 9ern)ataan &a%a" '#n&i!i &an i4 (erting'at ata+ i4 "a,e"+'. Pa&a (agian 'e&+a a'an &i,e%a!'an "engenai !tr+'t+r '#n&i!i +nt+' %eni &ari &+a 9i%ian "engg+na'an Ca!e..#4 )ang "e%i9+ti '#n&i!i &a%a" i"9+nan< '#n&i!i &a%a" rentang &an !tr+'t+r ga(+ngan.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal !
Modul Pemrograman Komputer
Bagian 1 KONDISI IF..THEN
A. Pengertian ondisi
Se(+a '#n&i!i a&a%a !+at+ 'ea&aan &i"ana 'ita &ia&a9'an 9a&a !+at+ 9i%ian. Unt+' "en)ata'an '#n&i!i (ia!an)a ter&a9at &+a (e!aran )ang &i(an&ing'an. Unt+' "e"(an&ing'an &+a (e!aran &i(+t+'an !+at+ #9erat#r re%a!i. O9erat#r re%a!i a&a%a #9erat#r )ang &i9a'ai +nt+' "e"(an&ing'an &+a (+a e'!9re!i arit"ati'. O9erat#r re%a!i )ang &ig+na'an &i &a%a" Pa!$a% Laar+! &a9at &i%iat 9a&a ta(e% (eri'+t ini 8abel % "PE:A8": :ELA(, "peratorrelasi
Artinya
X
%e(i (e!ar
`
%e(i 'e$i%
X
Le(i(e!ar!a"a&engan
`
Le(i'e$i%!a"a&engan
`X
Ti&a'!a"a&engan
B. (tr!kt!r ,f...8hen dan ,f...8hen....Else
Str+'t+r
IF...THEN
&an
IF...THE...ELSE
&ig+na'an
+nt+'
"en)ata'an
9er$a(angan (er!)arat. Per(e&aan &ari IF...THEN &engan IF...THEN...ELSE a&a%a &i&a%a" IF...THEN ti&a' &i(+at 9ern)ataan a9a(i%a !)arat ti&a' &i9en+i !e&ang'an &a%a" IF...THEN...ELSE &i(+at 9ern)ataan a9a(i%a !)arat ti&a' &i9en+i. Seingga &a%a" IF...THEN (i%a !)aratn)a &i9en+i "a'a 9ern)ataan !ete%a THEN a'an &i%a'!ana'an< ,i'a ti&a' &i9en+i ti&a' a&a 9er+(aan a9a9+n !e&ang'an &a%a" IF...THEN...ELSE (i%a !)aratn)a &i9en+i "a'a 9ern)ataan
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal !!
Modul Pemrograman Komputer !ete%a THEN a'an &i%a'!ana'an< ,i'a ti&a' &i9en+i "a'a 9ern)ataan !ete%a ELSE a'an &i%a'!ana'an.
Bent+' +"+" &ari !tr+'t+r IF...THEN &F : e)spresi lo"i)a ; T0'9 : pernyataan ;<
Bent+' +"+" &ari !tr+'t+r IF...THEN...ELSE &F : e)spresi lo"i)a ; T0'9 : pernyataan ; 'L$' : pernyataan ;<
E'!9re!i %#gi'a a&a%a !+at+ 9ern)ataan )ang an)a &a9at (erni%ai (enar ata+ !a%a TRUE #r FALSE .
Latihan %
Kita a'an "e"(+at !+at+ 9r#gra" 9er(e%an,aan !e(+a t#'#. Pr#gra" ini 9r#gra"
+nt+' "e"(eri'an 9#t#ngan &i!'#n !e(e!ar 1/^ +nt+' 9e%anggan
)ang (er(e%an,a 9a%ing !e&i'it &ari R9. 1/////. Unt+' it+ (+at%a !e(+a F#r" &engan &e!ain !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal !"
Modul Pemrograman Komputer
Ke"+&ian at+r 9r#9ertie! !e(agai (eri'+t omponen
Properties
Ial!e
B+tt#n1
Ca9ti#n
Ba)ar
La(e%1
Ca9ti#n
Harga
La(e% La(e%3
Ca9ti#n Ca9ti#n
Di!'#n TOTAL
E&it1
Tet
E&it
Tet
E&it3
Tet
/
K%i' &+a 'a%i 9a&a (+tt#n1 &an "a!+''an '#&e !e(agai (eri'+t proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar harga1 pot ; integer6 total ; real6 begin harga;
A9a(i%a 9r#gra" &ie'!e'+!i "a'a a'an "+n$+% ta"9i%an !e9erti (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal !#
Modul Pemrograman Komputer
A9a(i%a 'ita "engg+na'an !tr+'t+r IF0THEN0ELSE "a'a '#&e 9r#gra"n)a a&a%a !e(agai (eri'+t
proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar harga1 pot ; integer6 total ; real6 begin harga;
A9a(i%a &ie'!e'+!i a'an "enga!i%'an ni%ai )ang !a"a &engan !e(e%+"n)a
C. oidisi Lebih dari (at!
Da%a" !+at+ '#n&i!i ter'a&ang &i9er%+'an %e(i &ari !at+ e'!9re!i '#n&i!i. Unt+' it+ &i9er%+'an !+at+ #9erat#r +nt+' "eng+(+ng'an '#n&i!i )ang !at+ &engan %ainn)a. Di &a%a" Pa!$a% Laar+! #9erat#r (##%ean &ig+na'an +nt+' "eng+(+ng'an &+a (+a e'!9re!i %#gi'a.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal "$
Modul Pemrograman Komputer %. O9erat#r AND &ig+na'an +nt+' "eng+(+ng'an &+a (+a e'!9re!i %#gi'a
&an hanya a'an "enga!i%'an ni%ai (enar TRUE a9a(i%a 'e&+a e'!9re!i ter!e(+t (erni%ai (enar TRUE< teta9i a'an "enga!i%'an ni%ai !a%a FALSE a9a(i%a !a%a !at+ ata+ 'e&+a e'!9re!i (erni%ai !a%a FALSE. &. O9erat#r OR &ig+na'an +nt+' "eng+(+ng'an &+a (+a e'!9re!i %#gi'a
&an a'an "enga!i% 'an ni%ai (enar TRUE a9a(i%a !a%a !at+ ata+ 'e&+a e'!9re!i (erni%ai TRUE< teta9i hanya a'an (erni%ai !a%a FALSE a9a(i%a 'e&+a e'!9re!i (erni%ai !a%a FALSE . '. O9erat#r NOT ti&a' "eng+(+ng'an &+a (+a e'!9re!i %#gi'a. O9erat#r
NOT an)a "e"er%+'an !e(+a e'!9re!i %#gi'a. O9erat#r NOT &i9a'ai +nt+' "e"(a%i''an ni%ai e'!9re!i %#gi'a. O9erat#r NOT (erni%ai TRUE ,i'a e'!9re!i %#gi'a (erni%ai FALSE (egit+ 9+%a !e(a%i'n)a. *. O9erat#r IN (e'er,a 9a&a !e(+a i"9+nan. O9erat#r IN a'an "e"eri'!a
a9a'a !+at+ ni%ai "er+9a'an angg#ta &ari !+at+ i"9+nan. Ha!i%n)a TRUE (i%a ni%ai ter!e(+t "er+9a'an angg#ta i"9+nan.
Latihan &
Pa&a Latian (eri'+t 'ita a'an "e"(+at 9r#gra" "engenai #9erat#r AND. B+at%a 4#r" !e9erti ga"(ar (eri'+t ini
Ke"+&ian at+r 9r#9ertie! !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal "1
Modul Pemrograman Komputer omponen
Properties
Ial!e
B+tt#n1
Ca9ti#n
Ke%+%+!an
La(e%1
Ca9ti#n
Ni%ai
La(e%
Ca9ti#n
Ha!i%
E&it1
Tet
Ke"+&ian '%i' &+a 'a%i 9a&a (+tt#n &an "a!+''an '#&e (eri'+t
proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar nilai ; real6 begin nilai;
A9a(i%a 9r#gra" &ie'!e'+!i "a'a a'an "+n$+% ta"9i%an !e9erti (eri'+t
Latihan '
Pa&a Latian (eri'+t 'ita a'an "e"(+at 9r#gra" "engenai #9erat#r OR. B+at%a 4#r" !e9erti ga"(ar (eri'+t ini
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal "2
Modul Pemrograman Komputer
Ke"+&ian at+r 9r#9ertie!n)a !e(agai (eri'+t K#"9#nen
Pr#9ertie!
=a%+e
B+tt#n1
Ca9ti#n
K+%ia
La(e%1
Ca9ti#n
R+ang Ke%a!
La(e%
Ca9ti#n
E&it1
Tet
/
Ke"+&ian K%i' &+a 'a%i 9a&a (+tt#n1 &an "a!+''an '#&e (eri'+t 9r#$e&+re TF#r"1.B+tt#n1C%i$'Sen&er TO(,e$t ;ar r+ang integer (egin r+ang!trt#inte&it1.tet i4 r+ang #r r+ang3 ten %a(e%3.$a9ti#nK+%ia Pe"r#gra"an K#"9+ter e%!e %a(e%3.$a9ti#nK+%ia K#"9+ta!i Stati!ti'a en&
A9a(i%a 9r#gra" &ie'!e'+!i "a'a a'an "+n$+% ta"9i%an (eri'+t ini
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal "3
Modul Pemrograman Komputer
Latihan *
Pa&a Latian (eri'+ t 'ita a'an "e"(+at 9r#gra" "engena i #9erat#r IN. Pa&a 9r#gra" ini 9e%anggan teta9 "en&a9at'an 9#t#ngan arga. B+at%a 4#r" !e9erti ga"(ar (eri'+t ini
Ke"+&ian at+r 9r#9ertie!n)a !e(agai (eri'+t omponen
Properties
Ial!e
B+tt#n1
Ca9ti#n
Ba)ar
La(e%1
Ca9ti#n
Ban)a'
La(e%
Ca9ti#n
Pe%angganTeta9
La(e%3
Ca9ti#n
Ba)ar
E&it1
Tet
E&it
Tet
E&it3
Tet
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal "4
Modul Pemrograman Komputer Ke"+&ian K%i' &+a 'a%i 9a&a (+tt#n1 &an "a!+''an '#&e (eri'+t proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar tetap;integer6 banyak1bayar1pot;real6 begin banyak;
A9a(i%a 9r#gra" &ie'!e'+!i "a'a a'an "+n$+% ta"9i%an (eri'+t ini
D. (tr!kt!r , Bertingkat
S+at+
!tr+'t+r
IF...THEN...ELSE
"e"+ng'in'an
a&an)a
!tr+'t+r
IF...THEN...ELSE &i&a%"n)a. Ha% ini &i%a'+'an a9a(i%a !e(+a '#n&i!i "e"er%+'an !+at+ 9ern)ataan '#n&i!i %ain )ang (era&a &i&a%a" 9ern)ataan. Se$ara +"+" (ai' (agian THEN "a+9+n (agian ELSE (i!a "e"9+n)ai !tr+'t+r Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal "5
Modul Pemrograman Komputer '#n&i!i %ain. Str+'t+r !e9erti ini &i!e(+t !e(agai !tr+'t+r IF MA7EMUK ata+ IF BERTINGKAT Unt+' %e(i ,e%a!n)a 9erati'an (agan (eri'+t
&F:e)spresi lo"i)a; T0'9 Be"in :pernyataan; &F :e)spresi lo"i)a; T0'9:pernyataan;< 'L$':pernyataan;< 'nd< 'L$' Be"in :pernyataan; &F :e)spresi lo"i)a; T0'9 :pernyataan;< 'nd<
E. Blok (tatement
B%#' Sta"ent a&a%a 'e!at+an &ari (e(era9a 9ern)ataan. Bia!an)a B%#' State"ent &ig+na'an a9a(i%a a&a 9ern)ataan )ang %e(i &ari !at+ (ari!. Str+'t+r IF...THEN ata+ IF...THEN...ELSE "e"er%+'an (%#' ,i'a (agian 9ern)ataan !ete%a THEN ata+ (agian 9ern)ataan !ete%a ELSE a&a %e(i &ari !+at+ 9ern)ataan. Se(+a (%#' &i(ata!i #%e 'ata !i"9an be"in &an end. Pern)aan B%#' &a9at &i9erati'an 9a&a (agan &a%a" !tr+'t+r IF MA7EMUK &iata!.
Latihan G
Da%a" %atian 'a%i ini 'ita a'an "e"(+at 9r#gra" +nt+ ' "eng+r+t'an n (+a &ata "engg+na'an IF Berting'at. B+at%a !e(+a F#r" &engan &e!ain !e(agai Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal "
Modul Pemrograman Komputer (eri'+t
Ke"+&ian at+r 9r#9ertie!n)a !e(agai (eri'+t
omponen
Properties
Ial!e
B+tt#n1
Ca9ti#n
Ur+t
La(e%1
Ca9ti#n
Data A!a%
La(e%
Ca9ti#n
Data Ter+r+t
Li!t(#1
Ca9ti#n
Li!t(#
Ca9ti#n
Ke"+&ian K%i' &+a 'a%i 9a&a (+tt#n1 &an "a!+''an '#&e (eri'+t proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar %1&1'1y%1y&1y';real6 begin inp!t data listbo%.,tems.Add7inp!tbo7O,np!t DataO1 OS%
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal "!
Modul Pemrograman Komputer if %W<' then if &W<' then begin y%;<%6y&;<&6y';<'6 end else begin y%;<%6y&;<'6y';<&6 end else begin y%;<'6y&;<%6y';<&6 end else if %V' then if &V' then begin y%;<'6y&;<&6y';<%6 end else begin y%;<&6y&;<'6y';<%6 end else begin y%;<&6y&;<%6y';<'6 end6 o!tp!t data Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal ""
Modul Pemrograman Komputer listbo&.,tems.Add7floattostr7y%996 listbo&.,tems.Add7floattostr7y&996 listbo&.,tems.Add7floattostr7y'996 end6
A9a(i%a 9r#gra" &ie'!e'+!i "a'a a'an "+n$+% ta"9i%an (eri'+t ini
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal "#
Modul Pemrograman Komputer
Bagian 2 KONDISI CASE..OF
A. (tr!kt!r Case..."f
Str+'t+r '#n&i!i ter'a&ang "e"(+t+'an 9i%ian %e(i &ari &+a !eingga 9engg+naan IF...THEN...ELSE a'an "ene"+i 'en&a%a. Pa!$a% Laar+! "en)e&ia'an !tr+'t+r CASE...OF )ang &a9at &ig+na'an +nt+' "e"i%i &engan 'e"+ng'inan %e(i &ari &+a. Se$ara +"+" (ent+' !tr+'t+r CASE...OF a&a%a !e(agai (eri'+t
Case W/ariableV of Wkonstanta %V ; WpernyataanV Wkonstanta &V ; WpernyataanV Wkonstanta 'V ; WpernyataanV . . Else WpernyataanV End6
Da%a" !tr+'t+r CASE...OF =aria(e% &an '#n!tanta )ang &a9at &ig+na'an an)a%a )ang "e"9+n)ai ti9e integer ata+ $ar.
Latihan G
Unt+' %e(i "e"aa"i !tr+'t+r CASE...OF 'ita a'an "e"(+at 9r#gra" +nt+' "engit+ng ,+"%a 9e"(e% ian (a,+ &engan tiga +'+ran )ait+ S< M &an L. Unt+' it+ (+at%a !e(+a F#r" &engan &e!ain !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal #$
Modul Pemrograman Komputer
Ke"+&ian at+r 9r#9ertie!0n)a !e(agai (eri'+t omponen
Properties
Ial!e
B+tt#n1
Ca9ti#n
Be%i
La(e%1
Ca9ti#n
7+"%a
E&it1
Tet
/
Ra&i#Gr#+91
Ca9ti#n
U'+ranBa,+
Ite"!
S
Na"e
Ba,+
Me"#1
Line!
Ke"+&ian '%i' &+a 'a%i 9a&a (+tt#n1 &an "a!+''an '#&e (eri'+t proced!re 8orm%.B!tton&Click7(ender; 8"b#ect96 Iar banyak ; integer6 harga1 #!mlah ; real6 begin banyak;
Hal #1
Modul Pemrograman Komputer =;harga;< %%===6 %;harga;< %&G==6 &;harga;< %G===6 End6 !mlah ;
7OUang
yang
har!s
; Ointtostr7banyak996 dibayarkan
<
:p
Ofloattostr7#!mlah996 end6
A9a(i%a 9r#gra" &ie'!e'+!i "a'a a'an "+n$+% ta"9i%an (eri'+t ini
B. Case..."f dengan Beberapa onstanta dan :entang onstanta
Se(+a CASE..OF &i9er(#%e'an "e"9+n)ai %e(i &ari !at+ '#n!tanta. Se%ain it+ '#n!tanta ter!e(+t ,+ga (i!a &iganti &engan rentang ran"e tertent+. Rentang Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal #2
Modul Pemrograman Komputer &i&a%a" Pa!$a% &i&e4in i!i'an "engg+na'an tan&a ... Se%ain it+ '#n!tan ta )ang &ig+na'an (i!a "er+9a'an '#"(ina!i &ari &+a $ara ter!e(+t.
Contoh Case nomor of %..G1> ; harga ; %G===6 @..F1; harga ; &====6 %=..%&; harga ; &G===6 End.
Latihan @
Da%a" %atian 'a%i ini 'ita a'an "e"(+at 9r#gra" +nt+' "e"eri'!a n#"#r !e9at+. Unt+' it+ (+at%a !e(+a F#r" &engan &e!ain !e(agi (eri'+t
Ke"+&ian at+r 9r#9ertie!0n)a !e(agai (eri'+t K#"9#nen B+tt#n1
Ca9ti#n
Peri'!a
La(e%1
Ca9ti#n
N#"#r Se9at+
E&it1
Tet
/
Me"#1
Line!
Properties
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Ial!e
Hal #3
Modul Pemrograman Komputer K%i' &+a 'a%i 9a&a (+tt#n1 &an "a!+''an '#&e (eri'+t Proced!re 8orm%.B!tton'Click7(ender; 8"b#et96 /ar nomor;integer6 sepat!;string6 begin nomor;
Ke"+&ian a9a(i%a 9r#gra" &i e'!e'+!i "a'an a'an "+n$+% ta"9i%an (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal #4
Modul Pemrograman Komputer C. (tr!kt!r Camp!ran
Setia9 !tr+'t+r '#n&i!i (ai' IF..THEN..ELSE "a+9+n Str+'t+r CASE..OF "e"9+n)ai 'e%e(ian &an 'e'+rangann)a "a!ing0"a!ing. Seingga !angat &i"+ng'in'an &a%a" "e"(+at 9r#gra" +nt+' "engga(+ng'an 'e&+a !tr+'t+r ter!e(+t. Se(+a !tr+'t+r CASE...OF (#%e "e"9+n)ai !tr+'t+r CASE..OF %ain &i&a%a"n)a ata+ !tr+'t+r %ainn) a< "i!a%n)a IF0THEN0ELSE. Bent+' +"+"n)a &a9at &i%iat &a%a" (agan (eri'+t ini Case .. of .. ; begin X end6 ..; begin X case X of X;X end6 end6 .. ; if X then X else X end6
D. (oal)soal %. Se(+a !+9er"ar'et "e"(eri'an 9#t#ngan !e(e!ar 1.5^ +nt+' ,+"%a
9e"(e%ian &ari 'e%e(iann)a &ari R9 83///. 'itai'an (e!ar 9e"(e%ian a&a%a R9 1/////<"a'a )ang "en&a9at 9#t#ngan a&a%a )ang R9 1*///. B+at 9r#gra"n)a &. Se(+a Renta% CAR "e"9+n)ai 9erat+ran !e(agai (eri'+t< !at+ ,a"
9erta"a !ea "#(i% a&a%a R9 5///< ,a" (eri'+tn)a (ia)a !ea a&a%a R9
15///. A9a(i%a
'ita
Bertho Tantular Jurusan Statistika FMIPA UNPAD
"en)ea
"#(i%
!e%a"a
3
,a"<"a'a Hal #5
Modul Pemrograman Komputer 9erit+ngann)a a&a%a 1 5/// J 15///. B+at%a 9r#gra" +nt+' "engit+ng %a"a 9en)eaan &an (era9a (e!ar
!i 9e%anggan ar+!
"e"(a)ar '. Se(+a
%e"(aga
'+r!+! '#"9+ter
"e"9+n)ai
3
'riteria
&a%a"
9e"+ng+tan (ia)a +,ian +,ian %#'a% &an +,ian negara:SKS tia9 'riteria a&a%a !e(agai (eri'+t 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 KRITERIA
U7IAN LOKAL
U7IAN NEGARA:SKS
000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000 Ta+n'e1
R915//
R96///
Ta+n'e
R915///
R9*5//
Ta+n'e3
R95//
R91////
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 U,ian negara &i(eri'an 'e9a&a "aa!i!a )ang te%a "ene"9+ ,+"%a !'! %e(i &ari1 SKS. B+at 9r#gra" +nt+' "engit+ng ,+"%a (ia)a )ang ar+! &i!e&ia'an #%e !e#rang "aa!ia. In9+t Na"a "aa!i!a< Kriteria< &an ,+"%a SKS. O+t9+t 7+"%a +ang +,ian Petun!u)6 7una)an stru)tur CA$' den"an BLO/be"in = end.
*. Pene"+an in&e'! 9re!ta!i "aa!i!a a&a%a !e(agai (eri'+t
Ni%ai X -/ A *5` ni%ai ` -/
B
65` ni%ai ` *5
C
6/` ni%ai ` 65
D
ni%ai ` 6/
E
B+at 9r#gra"n)a +nt+' "engeta +i in&e'! 9re!ta!i !+at+ "ata '+%ia. B+at &a%a" 3 $ara 9en)e%e!aian )ait+ a. "engg+na'an !tr+'t+r IF0THEN &engan #9erat#r AND &an IN
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal #
Modul Pemrograman Komputer (. "engg+na'an !tr+'t+r IF0THEN0ELSE "a,e"+' $. "engg+na'an !tr+'t+r CASE
G. Di (e(era9a t#'# '#"9+ter "en,+a% ane'a &i!'et 9e"r#gra"an #rigina%<
&engan arga )ang (erane'a raga" 9+%a )ait+ 00000000000000000000000000000000000000000000000000000000000000000000000000000000 Pr#gra"
T#'#QA
T#'#QB
T#'#QC
00000000000000000000000000000000000000000000000000000000000000000000000000000000 C%i99er
5////
35///
Pa!$a%
5///
18*///
1-*5//
F#rtran
315///
3/////
3/55//
A!!e"(%er
////
/////
65//
/5//
000000000000000000000000000000000000000000000000000000000000000000000000000000000
B+at 9r#gra"n)a +nt+' "engit+ng ,+"%a )ang ar+! &i(a)ar #%e !e#rang 9e"(e%i &i!'et. In9+t 7eni! &i!'et 10 < T#'# A:B:C < (an)a' )ang &i(e%i.
O+t9+t 7+"%a )ang ar+! &i(a)ar.
Petun!u)6 7una)an stru)tur CA$' di dalam CA$'.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal #!
Modul Pemrograman Komputer
MODUL PENGULANGAN
PENDAHULUAN
Da%a" "#&+% ini a'an &i9e%a,ari "engenai ,eni!0,eni! 9eng+%angan &a%a" (aa!a 9e"r#gra"an "e%i9+ti 9eng+%angan F#r &an 9eng+%angan &engan '#n&i!i )ait+ i%e.. &an re9eat..+nti%. M#&+% ini ter&iri ata! &+a (agian )ait+ (agian 9erta"a "engenai 9eng+%angan "engg+na'an 4#r... Se&ang'an 9a&a (agian 'e&+a &i,e%a!'an "engenai 9eng+%angan &engan '#n&i!i )ait+ !tr+'t+r i%e.. &an re9eat..+nti%. Str+'t+r 9eng+%angan ata+ L##9ing "er+9a'an !tr+'t+r )ang !angat 9enting &a%a" (a!a 9e"r#gra"an. Karena &engan "engg+na'an !tr+'t+r 9eng+%angan 'ita &a9at "enge"at (an)a' "e"#ri &a%a" 9enger,aan 9r#gra" 'ita. O%e 'arena it+ Laar+! "en)e&ia'an tiga ,eni! 9eng+%angan )ait+ or...Do< ?hile...Do &an :epeat...Until. Ketiga ,eni! 9eng+%angan ini &a9at &ig+na'an &a%a" '#n&i!i 9eng+%angan )ang (er(e&a0(e&a.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal #"
Modul Pemrograman Komputer
Bagian 1 PENGULANGAN FOR..DO A. Peng!langan ": .. D"
Str+'t+r Peng+%angan FOR...DO "er+9a'an 9eng+%angan &engan ,+"%a )ang &itent+'an. Peng+%angan ini (ergant+ng &ari !+at+ ;aria(e% )ang (erti9e integer. Da%a" 9eng+%angan FOR...DO ar+! &itent+'an ni%ai aa% &an ni%ai a'ir &ari 9r#!e! 9eng+%angann)a. Setia9 9eng+%angan FOR...DO ;aria(e% ter!e(+t a'an (erta"(a ata+ (er'+rang &engan !at+. Se$ara +"+" (ent+' 9eng+%angan FOR0DO a&a )ait+
%. Peng+%angan &engan ;aria(e% (erta"(a &engan !at+ ": `;aria(%e 9eng#ntr#%X `(ata! (aaX to `(ata! ata!X do
`9ern)ataanX &. Peng+%angan &engan ;aria(e% (er'+rang &engan !at+ ": `;aria(%e 9eng#ntr#%X `(ata! (aaX do$nto `(ata! ata!X do
`9ern)ataanX
Contoh a;<=6 or i;<% to G do a;
akan menghasilkan nilai a < G
b;<%=6 or ;<%= do$nto @ do b;
akan menghasilkan nilai b < G
c;<= or #;<)G to G do c;
Bertho Tantular Jurusan Statistika FMIPA UNPAD
akan menghasilkan nilai c < =
Hal ##
Modul Pemrograman Komputer Latihan %
Kita a'an "e"(+at !e(+a 9r#gra" !e&erana +nt+' %e(i "e"aa"i !tr+'t+r FOR..DO. Unt+' it+ (+at%a 4#r" !e9erti (eri'+t ini
Ke"+&ian at+r 9r#9ertie!0n)a !e(agai (eri'+t omponen
Properties
B+tt#n1
Ca9ti#n
Me"#1
Line!
Ial!e
Peng+%angan
Ke"+&ian '%i' &+a 'a%i 9a&a (+tt#n1 &an "a!+''an '#&e (eri'+t ini
proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar i;integer6 begin for i;<% to @ do memo%.Lines.Add7OstatistikaO96 end
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1$$
Modul Pemrograman Komputer Ata+ T+%i!'an K#&e (eri'+t ini proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar i;integer6 begin for i;<> do$nto ' do memo%.Lines.Add7OstatistikaO96 end6
Sete%a &ie'!e'+!i a'an "enga!i%'an !e9erti (eri'+t ini
Ha!i% &ari 'e&+a '#&e ter!e(+t (erni%ai !a"a "e!'i9+n ni%ai aa% &an ni%ai a'ir )ang &iin9+t'an (er(e&a< 'arena &i&a%a" 9r#gra" FOR..DO &iata! )ang &i%iat a&a%a ,+"%a 9eng+%anggann)a.
Latihan & Da%a" %atian 'a%i ini 'ita a'an "e"(+at 9r#gra" +nt+' "engit+ng ni%ai
rata0rata !i!a &ari "ata '+%ia tertent+. In9+t (an)a' !i!a< ni%ai0ni%ain)a. O+t9+t Ni%ai rata0rata. Da%a" %atian 'a%i ini 'ita a'an "engg+na'an B%#' !tate"ent 9a&a !tr+'t+r F#r..D#. Unt+' it+ (+at%a 4#r" &engan &e!ain !e9erti (eri'+t ini
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1$1
Modul Pemrograman Komputer
Ke"+&ian at+r 9r#9ertie!0n)a !e(agai (eri'+t omponen
Properties
Ial!e
B+tt#n1
Ca9ti#n
Li!tB#1
Ca9ti#n
Rata0rata
La(e%1
Ca9ti#n
La(e%
Ca9ti#n
Data
E&it1
Tet
/
E&it
Tet
/
n
Ke"+&ian '%i' &+a 'a%i 9a&a (+tt#n1 &an "a!+''an '#&e (eri'+t ini proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar n1i;integer6 rata&;real6 begin inp!t data n;
Hal 1$2
Modul Pemrograman Komputer for i;<% to n do rata&;
Sete%a &ie'!e'+!i a'an "enga!i%'an !e9erti (eri'+t ini
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1$3
Modul Pemrograman Komputer
Bagian 2 PENGULANGAN DENGAN KONDISI
A. (tr!kt!r ?hile X Do
Str+'t+r 9eng+%angan HILE .. DO ti&a' &itent+'an (era9a (an)a' 9eng+%angan &i%a'+'an a'an teta9i "engg+na'an e'!9re!i %#gi'a +nt+' "engenti'an 9eng+%angan. Ber(e&a &engan !tr+'t+r FOR .. DO )ang "engenti'an 9eng+%angan an)a &engan (ata! 9en$a$aann)a !a,a. Da%a" !tr+'t+r HILE .. DO 9eng+%angan a'an ter+! &i%a'+'an !e%a"a e'!9re!i %#gi'a ter9en+i &an a'an (erenti 9a&a !aat e'!9re!i %#gi'a ti&a' ter9en+i. E'!9re!i %#gi'a )ang &ig+na'an &a%a" HILE .. DO !a"a &engan e'!9re!i %#gi'a )ang &ig+na'an &a%a" !tr+'t+r IF ..THEN. Bent+' +"+" !tr+'t+r HILE .. DO a&a%a !e(agai (eri'+t ?H,LE We,!pre!i lo$i,a D" Begin Wpernyataan6 X.. End6
B%#' !tate"ent &a%a" !tr+'t+r HILE .. DO a'an &i(+t+'an 'arena ,arang !e'a%i 9ern)ataan &a%a" !tr+'t+r ini an)a ter&iri &ari !at+ 9ern)ataan. Contoh a;<=6 ?hile aW
aaJ16 End6
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1$4
Modul Pemrograman Komputer Pern)ataan aaJ1 &i9er%+'an agar 9eng+%angan (i!a (erenti.
Latihan '
Da%a" %atian 'a%i ini 'ita a'an "e"(+at 9r#gra" +nt+' "engit+ng 4a't#ria% !e(+a (i%angan (+%at. In9+t (i%angan (+%at 9#!iti4. O+t9+t 4a't#ria%n)a. R+"+! 4a't#ria% a&a%a !e(agai (eri'+t
n> ? 2@@=@n1@n12@n Unt+' it+ (+at%a !e(+a F#r" &engan &e!ain !e(agai (eri'+t
Ke"+&ian at+r 9r#9ertie!0n)a !e(agai (eri'+t omponen
Properties
Ial!e
B+tt#n1
Ca9ti#n
n
La(e%1
Ca9ti#n
E&it1
Tet
/
E&it
Tet
/
F#r"1
Ca9ti#n
Fa't#ria%
n
Ke"+&ian '%i' &+a 'a%i 9a&a (+tt#n &an "a!+''an '#&e (eri'+t ini proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar n1i ; integer6 fak ; longint6 begin Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1$5
Modul Pemrograman Komputer inp!t data n;
Sete%a 9r#gra" &ie'!e'+!i a'an "enga!i%'an ,en&e%a !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1$
Modul Pemrograman Komputer B. (tr!kt!r :epeat .. Until
Sa"a &engan !tr+'t+r HILE .. DO< ! tr+'t+r 9eng+%angan REPEAT .. UNTIL ,+ga ti&a' &itent+'an (era9a (an)a' 9eng+%angan &i%a'+'an a'an teta9i "engg+na'an e'!9re!i %#gi'a +nt+' "engenti'an 9eng+%angan. Da%a" !tr+'t+r REPEAT .. UNTIL 9eng+%angan a'an (erenti 9a&a !aat e'!9re!i %#gi'a ter9en+i &an a'an ter+! &i%a'+'an !e%a"a e'!9re!i %#gi'a ti&a' ter9en+i. E'!9re!i %#gi'a )ang &ig+na'an &a%a" REPEAT .. UNTIL !a"a &engan e'!9re!i %#gi'a )ang &ig+na'an &a%a" !tr+'t+r IF..THEN. Bent+' +"+" !tr+'t+r REPEAT .. UNTIL a&a%a !e(agai (eri'+t
:EPEA8 Wpernyataan6 X. UN8,L We,!pre!i lo$i,a
Ti&a' !e9erti !tr+'t+r HILE .. DO )ang "e"er%+'an B%#' !tate"ent &a%a" 9eng+%angann)a< Str+'t+r REPEAT .. UNTIL ti&a' "e"(+t+'an B%#' State"ent "e!'i9+n %e(i &ari !at+ 9ern)ataan. Contoh a;<=6 :epeat memo%.Lines.Add7OstatistikaO96 a;
Pern)ataan aaJ1 &i9er%+'an agar 9eng+%angan (i!a (erenti.
Latihan *
Da%a" %atian 'a%i ini 'ita a'an "e"#&i4i'a!i 9r#gra" 9a&a Latian 3 &engan "eng+(a '#&e "en,a&i !e(agai (eri'+t Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1$!
Modul Pemrograman Komputer proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar n1i ; integer6 fak ; longint6 begin inp!t data n;
A9a(i%a 9r#gra" &ie'!e'+!i "a'a a'an "enga!i%'an ni%ai )ang !a"a &engan HILE ... DO.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1$"
Modul Pemrograman Komputer Latihan G
Pa&a %atian 'a%i ini 'ita a'an "e"(+at !e(+a 9r#gra" +nt+' "eng+r+t'an n (+a &ata &engan in9+t (an)a' &ata n &an ni%ai0ni%ai &atan)a. Unt+' it+ (+at%a !e(+a 4#r" &engan &e!ain !e(agai (eri'+t
Ke"+&ian at+r 9r#9ertie!0n)a !e(agai (eri'+t omponen
Properties
Ial!e
B+tt#n1
Ca9ti#n
In9+t
B+tt#n La(e%1
Ca9ti#n Ca9ti#n
La(e%
Ca9ti#n
Data Ter+r+t
E&it1
Tet
/
Li!tB#1
Ca9ti#n
Li!tB#1
Ca9ti#n
Ur+t'an XX n
Ke"+&ian '%i' &+a 'a%i 9a&a (+tt#n1 &an "a!+''an '#&e (eri'+t ini proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar i1n;integer6 begin n;
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1$#
Modul Pemrograman Komputer
Dan '%i' &+a 'a%i 9a&a (+tt#n &an "a!+''an '#&e (eri'+t ini proced!re 8orm%.B!tton&Click7(ender; 8"b#ect96 /ar i1#1n;integer6 a1b;real6 temp;string6 begin n;
Sete%a 9r#gra" &ie'!e'+!i a'an "enga!i%'an ,en&e%a !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 11$
Modul Pemrograman Komputer
C. (oal)soal %. B+at%a !e(+a 9r#gra" +nt+' "engit+ng ;arian! &an !i"9angan (a'+
&ari !+at+ &ata. In9+t a&a%a (an)a' &ata n &an ni%ai0ni%ai &atan) a. O+t9+tn)a a&a%a ;arian! &an !i"9angan (a'+. R+"+! ;arian! a&a%a !e(agai (eri'+t n
4̄ − ) n− 1
4
$
= ∑( i=1
i
&an !i"9angan (a'+ a&a%a a'ar &ari ;arian!. &. B+at%a !e(+a 9r#gra" +nt+' "engit+ng ni%ai 4+ng!i &i!tri(+!i
'+"+%ati4 Bin#"ia%. Dengan in9+t (an)a' 9er$#(aan n< (an)a' !+'!e! ' &an 9e%+ang !+'!e! 9. O+t9+t a&a%a ni%ai 9e%+ang '+"+%ati4 (in#"ia%. R+"+! +nt+' &i!tri(+!i '+"+%ati4 Bin#"ia% a&a%a !e(agai (eri'+t )
P ( 4 ≤) )=
∑ = 5
Bertho Tantular Jurusan Statistika FMIPA UNPAD
/
()
n p 5 ( 1− p )n− 5 5
Hal 111
Modul Pemrograman Komputer
MODUL ! VARIABEL BERINDEKS
PENDAHULUAN
Da%a" "#&+% ini a'an &i9e%a,ari "engenai ;aria(e% (erin&e'! )ang &i!e(+t &engan arra)< "en&e4ini!i'an ti9e< "engg+na'an !et &an ti9e ;aria(e% re$#r&. M#&+% ini ter&iri ata! &+a (agian )ait+ 9a&a (agian 9erta"a "engenai aria(e% (erin&e'! arra) )ang ter&iri ata! arra)< arra) "+%ti&i"en!i &an arra) &ina"i!. Pa&a (agian 'e&+a a'an &i,e%a!'an "e"(+at ti9e ;aria(e%< "engg+na'an !et &an "e"(+at re$#r& !e(agai ti9e ;aria(e%. Se"+a ;aria(e% )ang 'ita g+na'an 9a&a "#&+% !e(e%+"n)a an)a "e"+at !at+ r+ang !a,a< 9a&aa% !ering'a%i 'ita "e"(+t+'an !e(+a ;aria(e% &engan (an)a' te"9at. Mi!a%n)a !a,a ;aria(e% ? "e"9+n)ai ni%ai0ni%ai 1< 3< *< . Bia!an)a 9en&e4ini!ian ni%ai0ni%ai &ari ;aria(e% ter!e(+t "engg+na'an in&e'! !e9erti (eri'+t ini ?1 1< ? 3< ?3 * &an ? . Da9at &i'ata'an (aa ;aria(e% ? "e"9+n)ai r+ang )ang te"9atn)a &i&e4ini!'an !e(agai in&e'!. Da%a" Baa!a Pe"r#gra"an Laar+! te%a &i!e&ia'an ti9e ;aria(e% (erin&e'! !e9erti ini )ang &i!e(+t &engan arra).
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 112
Modul Pemrograman Komputer
Bagian 1 ARRA"
A. Array
Arra) a&a%a !e(+a ti9e ;aria(e% )ang "e"i%i'i (an)a' r+ang. Arra) ,+ga &i!e(+t !e(agai ;aria(e% (erin&e' !. Setia9 in&e'! )ang a'an &ig+ana'an &a%a" ;aria(e% (erti9e arra) ar+! &i&e4ini!'an 9a&a (agian &e'%ara!i. U"+"n)a in&e'! &i&e4ini!'an !e(agai !e(+a rentang ni%ai integer. Da%a" !at+ ;aria(e% arra) !e"+a r+ang )ang a&a ar+! "e"i%i'i ti9e )ang !a"a. Se$ara +"+" $ara 9en&e'%ara!ian ;aria(e% arra) a&a%a !e(agai (eri'+t
9ama3Variabel 6 Arraynilai3a(al..nilai3a)hir o# tipe3variabel
Contoh
=ar Na"a Arra)1..1/ #4 !tring
"e"i%i'i 1/ r+ang &engan ti9e !tring
IPK Arra)5..15 #4 rea%
"e"i%i'i 11 r+ang &engan ti9e rea%
n#"#r Arra)/..5 #4 integer
"e"i%i'i 6 r+ang &engan ti9e integer
Per%+ &i'eta+i (aa an)a in&e'! )ang &i&e4ini!i'an )ang &a9at &ig+na'an 9a&a ;aria(e% arra) ter!e(+t. Mi!a%n)a +nt+' ;aria(e% IPK 9a&a $#nt# &iata! "e"i%i'i in&e'! &ari 5 ingga 15 teta9i ti&a' "e"i%i'i in&e'! 1 !a"9ai < ;aria(e% Na"a ti&a' "e"i%i'i in&e'! / &an ;aria(e n#"#r ti&a' "e"i%i'i in&e'! %e(i &ari 5. Artin)a a9a(i%a 'ita "en&e4ini!i'an IPK3 ata+ Na"a/ ata+ n#"#r* a'an "enga!i%'an err#r 9a&a !aat &ie'!e'+!i. Be(era9a #(,e' &a%a" Laar+! "er+9a'an ;aria(e% (erti9e arra) !e9erti Li!tB#< C#"(#B# &an StringGri&. Se"+a #(,e' (erti9e arra) )ang a&a &a%a" Laar+! "e"i%i'i ti9e ;aria(e% !tring &engan ni%ai aa% in&e'! a&a%a n#% / &an ni%ai a'ir a&a%a (an)a'n)a &ata )ang &iin9+t'an.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 113
Modul Pemrograman Komputer
Latihan %
Da%a" %atian 'a%i ini 'ita a'an "e"(+at 9r#gra" +nt+' "engit+ng rata0rata "engg+na'an arra). Unt+' it+ (+at%a !e(+a F#r" &engan &e!ain !e(agai (eri'+t
Ke"+&ian at+r 9r#9ertie!n)a !e(agai (eri'+t omponen B+tt#n1
Ca9ti#n
B+tt#n
Ca9ti#n
Me"#1
Line!
E&it1
Tet
Properties
Hit+ng
Ial!e
Ber!i'an /
K%i' &+a 'a%i 9a&a (+tt#n1 &an "a!+''an '#&e !e(agai (eri'+t proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar i1n;integer6 rata1total;real6 ;array%..' of real6 begin total;<=6 n;
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 114
Modul Pemrograman Komputer for i;<% to n do begin i;
B. Array -!ltidimensi
Arra) "+%ti&i"en!i a&a%a arra) )ang "e"9+n)ai &i"en!i n " !a%a !at+ 9engg+naan arra) "+%ti&i"e!i a&a%a &a%a" a% #9era!i "atri'!.
Latihan &
Pa&a %atian 'a%i ini 'ita a'an "e"(+at !e(+a 9r#gra" "engg+na'an !tringgri&. Unt+' it+ (+at%a !e(+a F#r" &engan &e!ain !e9erti ga"(ar (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 115
Modul Pemrograman Komputer
Ke"+&ian at+r 9r#9ertie!n)a !e(agai (eri'+t omponen
Properties
Ial!e
B+tt#n1
Ca9ti#n
Me"#1
Line!
Hit+ng
Stringgri&1
R#$#+nt
5
C#%$#+nt
5
G#e&iting
Tr+e
K%i' &+a 'a%i 9a&a (+tt#n1 &an "a!+''an '#&e !e(agai (eri'+t proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar i1n1#;integer6 ;array%..*1%..* of real6 begin for i;<% to * do begin
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 11
Modul Pemrograman Komputer for #;<% to * do begin i1#;
C. Array Dinamis
Arra) )ang ti&a' "e"i%i'i +'+ran ata+ &i"en!i )ang teta9. Arra) !e9eri ini &i&e'%ara!i'an &engan (ent+' !e9erti (eri'+t
Array of tipe*a!ar
Latihan '
Pa&a Pr#gra" )ang te%a &i(+at 9a&a Latian +(a%a '#&e &a%a" 9r#!e&+r b!tton% &engan '#&e !e(agi (eri'+t proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar i1n1#;integer6 ;array of array of real6
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 11!
Modul Pemrograman Komputer begin setlength71%=1%=96 for i;<% to * do begin for #;<% to * do begin i1#;
Latihan *
Da%a" %atian 'a%i ini 'ita a'an "e"(+at 9r#gra" +nt+' "en$ari in;er &ari !+at+ "atri'!. S)arat !e(+a "atri'! agar &i9er#%e in;ern)a a&a%a "atri'! ter!e(+t ar+! (er(ent+' (+,+r!ang'ar &an n#n !ing+%ar &eter"inann)a ti&a' n#%. Da%a" 9r#gra" ini a'an 'ita (ata!i +nt+' &i"en!i "atri'! 5 5. Da%a" "engit+ng "atri'! (er&i"en!i %e(i &ari 'ita &a9at "engg+na'an a%g#rit"a SEEP )ang %ang'a0%ang'an)a a&a%a !e(agai (eri'+t %. Tent+'an a)) +nt+' !etia9 ) 1<< ...< n &. Ka%i'an (ari! 'e ) "atri'! A &engan 1: Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 11"
Modul Pemrograman Komputer '. Unt+' !etia9 i )
aTent+'an B ai) (K+rang'an (ari! 'e i &engan B 'a%i (ari! 'e ) $Hit+ng ai) 0B:D *. Hit+ng a)) 1:D
B+at%a !e(+a F#r" &engan &e!ain !e(agai (eri'+t
Ke"+&ian at+r%a 9r#9ertie!n)a !e(agai (eri'+t
omponen
Properties
Ial!e
B+tt#n1
Ca9ti#n
In;er!
La(e%1
Ca9ti#n
N "a 5
E&it1
Tet
/
Stringgri&1
R#$#+nt
5
C#%$#+nt
5
G#e&iting R#$#+nt
Tr+e 5
C#%$#+nt
5
G#e&iting
Fa%!e
Stringgri&
Agar !tringgri& !e$ara #t#"ati! "engi'+ti (e!ar &i"en!i "a'a '%i' &+a 'a%i 9a&a E&it1 &an "a!+''an '#&e (eri'+t ini Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 11#
Modul Pemrograman Komputer 9r#$e&+re TF#r"1.E&it1CangeSen&er TO(,e$t ;ar n integer (egin i4 e&it1.tet`X ten (egin n!trt#inte&it1.tet i4 n`6 ten (egin !tringgri&1.C#%C#+ntn !tringgri&.C#%C#+ntn !tringgri&1.r#C#+ntn !tringgri&.r#C#+ntn en& en& en&
K%i' &+a 'a%i 9a&a (+tt#n1 &an "a!+''an '#&e (eri'+t ini
proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar A1B ; array%..G1%..G of real6 i1#1k1n ; integer6 d1c;real6 begin n;
Hal 12$
Modul Pemrograman Komputer for k;<% to n do begin d;
A9a(i%a 9r#gra" &ie'!e'+!i "a'a a'an &i9er#%e a!i% !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 121
Modul Pemrograman Komputer
D. (oal)soal %. B+at%a 9r#gra" +nt+' "engit+ng "e&ian "engg+na'an arra). &. B+at%a !e(+a 9r#gra" +nt+' "engit+ng rata0rata ar"#ni' &an
rata0rata +'+r &engan r+"+! !e(agai (eri'+t
Rata0rata Har"#ni'
0=
n n
1/ 4 ∑ =
i
i 1
√ ∏= 4 n
Rata0rata U'+r
n
-=
i
i 1
'. B+at 9r#gra" +nt+' "enga%i'an "atri'! A 3 &an "atri'! B 3 *. B+at 9r#gra" +nt+' "engit+ng in;er! "atri'! A "engg+na'an
A%g#rit"a A&,+!t &engan "atri'! gan&engan I. Lang'a0%ang'an)a a&a%a !e(agai (eri'+t %. Tent+'an B a)) +nt+' !etia9 ) 1<< ...< n &. Ka%i'an (ari! 'e ) "atri'! A &engan 1: B '. Unt+' !etia9 i ) Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 122
Modul Pemrograman Komputer aTent+'an B ai) (K+rang'an (ari! 'e i &engan B 'a%i (ari! 'e ) *. Ha!i%n)a in;er!n)a a&a%a "atri'! gan&engann)a
Petun!u)6 Buat Datri)s beru)uran n 5 n yan" dipartisi men!adi n 5 n untu) matri)s yan" a)an diinvers)an dan n 5 n untu) matri)s "anden"an berbentu) matri)s identitas.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 123
Modul Pemrograman Komputer
Bagian 2 TIPE# SET DAN RECORD
Se%ain "engg+na'an ti9e &ata )ang !+&a a&a &i&a%a" Laar+!< 'ita ,+ga &a9at "en&e4ini!i'an ti9e &ata 'ita !en&iri. Tent+n)a +nt+' "e%a'+'an a% ter!e(+t 'ita ar+! "e"(+at &e'%ara!i ti9e ;aria(e% )ang a'an &ig+na'an !e(e%+" "en&e'%ara!i'an ;aria(e%.
A. 8ipe
Kita (i!a "en&e4ini!i'an ti9e &ata. Ti9e )ang 'ita &e4ini!i'an &a9at &i9a'ai +nt+' 9en&e'%ara!ian '#n!tanta ata+ ;aria(e%.
Latihan %
Da%a" %atian 'a%i ini 'ita a'an "e"(+at 9r#gra" +nt+' "engit+ng rata0rata "engg+na'an ti9e. Unt+' it+ (+at%a !e(+a F#r" &engan &e!ain !e(agai (eri'+t
Ke"+&ian at+r 9r#9ertie!n)a !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 124
Modul Pemrograman Komputer omponen
Properties
Ial!e
B+tt#n1
Ca9ti#n
Hit+ng
B+tt#n
Ca9ti#n
Ber!i'an
Me"#1
Line!
E&it1
Tet
/
K%i' &+a 'a%i 9a&a (+tt#n1 &an "a!+''an '#&e !e(agai (eri'+t proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 8ype /ektor
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 125
Modul Pemrograman Komputer B. (et
Set a&a%a ti9e +nt+' !e,+"%a angg#t a &ari !+at+ ti9e !e&erana. Mi!a%n)a $ar &an ()te. Cara 9en+%i!an !et a&a%a !e(agai (eri'+t
type 9ama3tipe ? set o# data3sederhana
Se%ain it+ 9a&a !et ,+ga &a9at &i&e4ini!i'an !e'e%#"9#' (i%angan ata+ !e'+"9+%an 'ara'ter. C#nt# 9en&e4ini!ian !et a&a%a !e(agai (eri'+t Kata !et #4 $ar Bi%angan !et #4 ()te Ang'a !et #4 /..'ara'ter !et #4 a ..
C. :ecord
Re$#r& a&a%a ti9e &ata ter!tr+'t+r )ang (eri!i !e,+"%a &ata< &an "a!ing0"ai!ng &a9at (er(e&a ti9e. Re$#r& (an)a' &ig+na'an +nt+' "enangani &ata(a!e. Pen&e'%ara!iann)a !e(agai (eri'+t
Type namaTipeReor# / reor# #a0tar1 tipe1) #a0tar2 tipe2) en#)
A9a(i%a arra) &a9at "ena"9+ng (an)a' ;aria(e% &engan ti9e !a"a< re$#r&! &a9at "ena"9+ng (an)a' ;aria(e% &engan ti9e )ang (er(e&a0(e&a. =aria(e%0;aria(e% ini &i!e(+t &engan Fie%&!. Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 12
Modul Pemrograman Komputer Gr+9 ;aria(e%:4ie%&! &a9at &i9er%a'+'an !e(agai !e(+a +nit ata+ ;aria(e%. Kita &a9at "engg+na'an re$#r&! +nt+' "ene"9at'an in4#r"a!i )ang (era!a% &ari #(,e' )ang !a"a< "i!a%n)a in4#r"a!i "engenai "#(i% !e(agai (eri'+t %. 7eni! M#(i% !tring &. U'+ran "e!in rea% '. ta+n 9r#&+'!i integer
Kita &a9at "eng+"9+%'an ti9e0ti9e ;aria(e% (er(e&a ini 'e &a%a" !at+ re$#r&! )ang "ere9re!enta!i'an !e(+a "#(i%.
Latihan &
Kta a'an "e"(+at 9r#gra" +nt+' "ena"9i%'an in4#r"a!i &ari "#(i% !e9erti 9a&a $#nt# !e(e%+"n)a. B+at%a !e(+a F#r" &engan &e!ain !e9erti (eri'+t ini
Pa&a (agian type &a%a" !#+r$e e&it#r ta"(a'an (ari! '#&e (eri'+t Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 12!
Modul Pemrograman Komputer
8Car < record -odelName; string6 Engine; (ingle6 -odelMear; ,nteger6 end6
Ke"+&ian '%i' &+a 'a%i (+tt#n1 &an t+%i! '#&e (eri'+t
proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar Car; 8Car6 begin Car.-odelName;<,np!tbo7O,nfo -obilO1O,np!t -odel -obil; O1OO96 Car.Engine;
; O Car.-odelName96
memo%.Lines.add7OUk!ran -esin ; O floattostr7Car.Engine9 OCCO96 memo%.Lines.add7O8ah!n Prod!ksi ; O inttostr7Car.-odelMear996 end6
A9a(i%a 9r#gra" &i e'!e'+!i a'an "enga!i%'an !e9erti ga"(ar &i(aa ini
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 12"
Modul Pemrograman Komputer
Da%a" $#nt# ini 'ita &a9at "en&e4ini!i'an !e(+a ti9e (ar+ re$#r&! "engg+na'an 'ata t)9e. Perati'an '#&e 9r#gra" (eri'+t ini type 8Car < record -odelName; string6 Engine; (ingle6 -odelMear; ,nteger6 end6
Da%a" 9r#gra" ter!e(+t 'ita "ena"(a'an +r+4 T 9a&a 'ata Car +nt+' "engin&i'a!i'an (aa 9a&a ini a&a%a !e(+a ti9e &an (+'an !e(+a ;aria(e%. Na"a ;aria(e% !e9erti Car< H#+r< U!erNa"e< teta9i na"a t)9e !e9erti TCar< TH#+!e< an& TU!erNa"e. Ha% ini "er+9a'an (aa!a !tan&ar &a%a" Pa!$a%. a't+
'ita
"e"(+t+'an
!e(+a
ti9e
(ar+<
'e"+&ian
'ita
ar+!
"en&e'%ara!i'an !e(+a ;aria(e% "engg+na'an ti9e ter!e(+t 'ita &a9at "en+%i!'ann)a !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 12#
Modul Pemrograman Komputer /ar Car; 8Car6
A9a(i%a 'ita a'an "en)i"9an !e(+a ni%ai 'e&a%a" !a%a !at+ ;aria(e%:4ie%&! ta&i< "a'a 'ita &a9at "en+%i!'ann)a !e(agai (eri'+t
Car.-odelName
D. Soal-soal
1. B+at%a !e(+a 9r#gra" +nt+' "engin9+t'an &ata "engenai "aa!i!a !e(agai (eri'+t Na"a
!tring
NPM
integer
A%a"at
String
IPK
rea%
7+"%a SKS
integer
Petun!u)6 7una)an records . B+at%a !e(+a 9r#gra" +nt+' "engin9+t'an &ata "engenai 9egaai !e(agai (eri'+t Na"a
!tring
A%a"at
String
Ga,i
rea%
A(!en
integer
Petun!u)6 7una)an Tipe dan records
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 13$
Modul Pemrograman Komputer
MODUL $ PROSEDUR DAN FUNGSI
PENDAHULUAN
Da%a" "#&+% ini a'an &i9e%a,ari "engenai 9r#!e&+r &an 4+ng!i )ang "e%i9+ti (agai"ana $ara "e"(+at &an $ara "en,a%an'an 9r#!e&+r &an 4+ng!i. Se%ain it+ ,+ga &i9e%a,ari (agai"ana "e"an4aat'an 9r#!e&+r &an 4+ng!i )ang te%a a&a. M#&+% ini ter&iri ata! &+a (agian )ait+ 9a&a (agian 9erta"a "engenai (agai"ana "e"(+at 9r#!e&+r &an "engg+na'ann)a &i &a%a" 9r#gra". Se&ang'a n 9a&a (agian 'e&+a "engenai (agai"ana "e"(+at 4+ng!i &an "engg+na'ann)a 9a&a 9r#gra". Pr#!e&+r &an 4+ng!i "er+9a'an (agian &ari !+at+ 9r#gra" ata+ &engan 'ata %ain &i!e(+t !e(agai !+( 9r#gra". Pr#!e&+r &an 4+ng!i &a%a" 9en+%i!ann)a &i%a"(ang'an &engan !at+ 'ata. Pr#!e&+r "er+9a'an 9#t#ngan 9r#gra" )ang (er&iri !en&iri )ang ti&a' "e"(+t+'an #9era!i &ari #(,e' %ain. Se(a%i'n)a 4+ng!i "er+9a'an 9#t#ngan 9r#gra" )ang (ergant+ng 9a&a #9era!i &ari #(,e' %ain. O%e 'arena it+ 4+ng!i !e%a%+ "enge"(a%i'an !e(+a ni%ai &a%a" 9r#!e!n)a !e&ang'an 9r#!e&+r ti&a' "enga"(a%i'an ni%ai &a%a" 9r#!e!n)a.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 131
Modul Pemrograman Komputer
Bagian 1 PROSEDUR
A. Proced!re
Pr#$e&+re a&a%a (agian 9r#gra" )ang (eri!i !erang'aian %ang'a0%ang'a tertent+. Pr#!e&+r "er+9a'an 9#t#ngan 9r#gra" )ang (er&iri !en&iri )ang ti&a' "e"(+t+'an #9era!i &ari #(,e' %ain. Kita ti&a' &a9at "en+%i!'an #9era!i "ate"ati'a tera&a9 9r#!e&+r. Pr#!e&+r &i&e'%ara!i'an &i aa% 9r#gra" !e(e%+" 9r#gra" +ta"a "ain 9r#gra" &i%a'!ana'an. Pr#!e&+r ,+ga ti&a' a'an &i,a%an'an a9a(i%a ti&a' &i9anggi% &i&a%a" "ain 9r#gra". Se$ara +"+" !e(+a 9r#!e&+r &a9at (er,a%an 9a&a 9r#gra" +ta"a< &i &a%a" 4+ng!i "a+9+n &i &a%a" 9r#!e&+r %ainn)a. De'%ara!i 9r#$e&+re )ang 9a%ing !e&erana a&a%a
Proced!re Wnama proced!reV6 Begin Xperintahpernyataan6 end6
Latihan %
Da%a" %atian 'a%i ini 'ita a'an "e"(+at 9r#gra" +nt+' "engit+ng &i!tri(+!i 9e%+ang (in#" &engan "engg+na'an 9r#$e&+re. R+"+! 4+ng!i 9e%+ang (in#"ia% a&a%a !e(agai (eri'+t
n ' n0' 9 C1 0 9D '
PC? N 'D N 9C'D N
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 132
Modul Pemrograman Komputer
+nt+' ' N /< 1< < . . . < '. &an
n nO ' N ' O C n 0 ' D O
B+at%a !e(+a F#r" &engan &e!ain !e9erti (eri'+t ini
Ke"+&ian at+r%a 9r#9ertie! !e(agai (eri'+t
omponen
Properties
Ial!e
B+tt#n1
Ca9ti#n
La(e%1
Ca9ti#n
N
Hit+ng
La(e%
Ca9ti#n
?
La(e%3
Ca9ti#n
P?
E&it1
Tet
/
E&it
Tet
/
E&it3
Tet
/
Pa&a S#+r$e e&it#r t+%i!'an '#&e (eri'+t ini !ete%a i"9%e"entati#n proced!re faktorial7;integer6 /ar fak;longint96 /ar i;integer6 begin fak;<%6 if V= then
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 133
Modul Pemrograman Komputer begin for i;<% to do fak;
proced!re kombinasi7n1;integer6 /ar kom;real96 /ar fn1f1fn;longint6 begin faktorial7n1fn96 faktorial71f96 faktorial7n)1fn96 kom;
K%i' &+a 'a%i 9a&a (+tt#n &an "a!+''an '#&e !e(agai (eri'+t proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar n1;integer6 hasil1p1kn;real6 begin n;
Sete%a &ie'!e'+!i "a'a a'an 'e%+ar ta"9i%an !e9erti (eri'+t ini Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 134
Modul Pemrograman Komputer
B. Soal-soal
Langganan PDAM &i'#ta A &ie%#"9#''an "en,a&i 3 g#%#ngan. Setia9 g#%#ngan "e"9+n)ai tari4 9er "eter '+(i' &an arga !ea "eteran 9er (+%an. G#%#ngan
3
Tari4:"
!ea "eteran
A
R9 3//
R9 5///
B
R9 5/
R9 35//
C R9 1*5 R9 5// B+at 9r#gra" )ang a'an "engit+ng (ia)a t#ta% %angganan< &engan in9+t na"a< a%a"at< 9e"a'aian &an g#%#ngan. %ang'a0%ang'a B+at%a 9r#$e&+re (eri'+t 1. Ba$a &ata . Hit+ng 3. 7+&+% &i9anggi% #%e 9r#$e&+re $eta' . Ceta' Pa&a 9r#$e&+re it+ng< (+at%a !+!+nan (eri'+t 1. "engit+ng tari4 9er "
3
&an !ea "eteran 9a'ai !tr+'t+r $a!e
. "engit+ng ,+"%a 9e"(a)aran 3. "engit+ng t#ta% 9e"(a)aran
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 135
Modul Pemrograman Komputer
Bagian 2 FUNGSI
A. !ngsi
F+ng!i a&a%a (agian 9r#gra" )ang (eri!i !erang'aian %ang'a0%ang'a tertent+ )ang "enga!i%'an ni%ai. F+ng!i "er+9a'an 9#t#ngan 9r#gra" )ang ti&a' (er&iri !en&iri )ang "e"(+t+'an #9era!i &ari #(,e' %ain. Kita &a9at "en+%i!'an #9era!i "ate"ati'a tera&a9 4+ng!i 'arena 4+ng!i "enge"(a%i' an !e(+a ni%ai. Se9erti a%n)a 9r#!e&+r< 4+ng!i ,+ga &i&e'%ara!i' an &i aa% 9r#gra" !e(e%+" 9r#gra" +ta"a "ain 9r#gra" &i%a'!ana'an &an ti&a' a'an &i,a%an'an a9a(i%a ti&a' &i9anggi% &i&a%a" "ain 9r#gra". Se$ara +"+" !e(+a 4+ng!i &a9at (er,a%an 9a&a 9r#gra" +ta"a< &i &a%a" 4+ng!i "a+9+n &i &a%a"
9r#!e&+r %ainn)a.
Pen&e'%ara!ian F+ng!i a&a%a !e(agai (eri'+t
!nction Wnama f!ngsiV6 Begin X Xperintahpernyataan X end6
C#nt# !nction 8ambah71y;integer9;integer6 Begin 8ambah;<y6 End6
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 13
Modul Pemrograman Komputer Pa&a !e(+a 4+ng!i ,i'a 9ara"eter ni%ai an)a &i%eat'an 9a&a 9ara"eter a't+a%9ara"eter !ea't+ 4+ng !i ata+ 9r#!e&+r &i9a nggi% "a'a 9er+(aann)a an)a ter,a&i &i&a%a" 4+ng!i !e&ang'an Ni%ai )ang "e"anggi% ti&a' a'an (er9engar+. Ini &i!e(+t &engan meman""il #un"si den"an parameter nilai.
Pa&a !e(+a 4+ng!i ,i'a 9ara"eter ;arai(e% &i%eat'an 9a&a 9ara"eter a't+a%9ara"eter !ea't+ 4+ng !i ata+ 9r#!e&+r &i9a nggi% "a'a 9er+(aann)a ti&a' an)a ter,a&i &i&a%a" 4+ng!i ,+ga Ni%ai )ang "e"anggi% . Ini &i!e(+t &engan meman""il #un"si den"an parameter varaibel.
Latihan %
Da%a" %atian 'a%i ini 'ita a'an "e"(+at 9r#gra" +nt+' "engit+ng &i!tri(+!i 9e%+ang '+"+%ati4 &i!tri(+!i (in#"ia% &engan "engg+na'an 4+ng!i. R+"+! 4+ng!i 9e%+ang '+"+%ati4 (in#"ia% a&a%a !e(agai (eri'+t
5
P ( 4 ≤ 5 )=
∑( ) =/
+nt+' ' N /< 1< < . . . < '. &an
n p ) ( 1 − p )n− ) )
)
n nO ' N ' O C n 0 ' D O
B+at%a !e(+a F#r" &engan &e!ain !e9erti (eri'+t ini
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 13!
Modul Pemrograman Komputer Ke"+&ian at+r%a 9r#9ertie! !e(agai (eri'+t omponen
Properties
Ial!e
B+tt#n1
Ca9ti#n
La(e%1
Ca9ti#n
N
Hit+ng
La(e%
Ca9ti#n
?
La(e%3
Ca9ti#n
P?`
E&it1
Tet
/
E&it E&it3
Tet Tet
/ /
Pa&a S#+r$e e&it#r t+%i!'an '#&e (eri'+t ini !ete%a i"9%e"entati#n f!nction faktorial7;integer9;longint6 /ar i;integer6 begin faktorial;<%6 if V= then begin for i;<% to do faktorial;
f!nction kombinasi7n1;integer9;real6 begin kombinasi;
K%i' &+a 'a%i 9a&a (+tt#n &an "a!+''an '#&e !e(agai (eri'+t
proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 13"
Modul Pemrograman Komputer /ar n11k;integer6 hasil1p;real6 begin n;
Sete%a &ie'!e'+!i "a'a a'an 'e%+ar ta"9i%an !e9erti (eri'+t ini
B. !ngsi)f!ngsi (tatistika
Laar+! te%a "en)e&ia'an 4+ng!i04+ng!i '+!+! !tati!ti'a )ang (i!a &ig+na'an +nt+' "engit+ng rata0rata< ;arian!< '+a&rat ,+"%a &an %ain0%ain. Caran)a &engan "en+%i!'an +nit math 9a&a ea&er 9r#gra" !e(agai (eri'+t
Unit%6
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 13#
Modul Pemrograman Komputer interface !ses ?indo$s1 -essages1 (ysUtils1 Iariants1 Classes1 Kraphics1 Controls1 orms1 Dialogs1 (tdCtrls1 Krids1 math6
type 8orm% < class78orm9 (tringKrid%; 8(tringKrid6 B!tton%; 8B!tton6 -emo%; 8-emo6 proced!re B!tton%Click7(ender; 8"b#ect96 pri/ate 4 Pri/ate declarations 5 p!blic 4 P!blic declarations 5 end6
Latihan &
Pa&a %atian 'a%i ini 'ita a'an "e"(+at !e(+a 9r#gra" "engg+na'an Unit math. Unt+' it+ (+at%a !e(+a F#r" &engan &e!ain !e9erti ga"(ar (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 14$
Modul Pemrograman Komputer
Ke"+&ian at+r 9r#9ertie!n)a !e(agai (eri'+t omponen
Properties
Ial!e
B+tt#n1
Ca9ti#n
Me"#1
Line!
Hit+ng
Stringgri&1
R#$#+nt
5
C#%$#+nt
5
G#e&iting
Tr+e
K%i' &+a 'a%i 9a&a (+tt#n1 &an "a!+''an '#&e !e(agai (eri'+t proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar i1n;integer6 total1rata1/arians;real6 ;array of do!ble6 begin setlength71%=96
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 141
Modul Pemrograman Komputer n;
C. !ngsi ,ntegral
Da%a" i%"+ !tati!ti'a (an)a' &i(+t+'an 9erit+ngan "engg+na'an integra% ter+ta"a &a%a" "engit+ng ni%ai &i!tri(+!i 9e%+ang '#ntin+. Di&a%a" Laar+! 4+ng!i integra% ti&a' &i!e&ia'an !eingga 'ita ar+! "engg+na'an 9en&e'atan n+"eri' &engan "et#&e integra!i "#nte $ar%#. A%g#rit"a integra!i "#nte $ar%# &a9at &i%iat 9a&a (agan (eri'+t ini
Kambar %. Bagan -etode ,ntegrasi -onte Carlo
Keterangan a
(ata! (aa integra%
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 142
Modul Pemrograman Komputer (
(ata! ata! integra%
n
(an)a' 9eng+%angan
g?
4+ng!i )ang a'an &iintegra%'an
Di%iat &ari a%+r (agan ter!e(+t ter%iat (aa !e"a'in (e!ar ni%ai n "a'a 9en&e'atan ini a'an !e"a'in (ai'. Dengan &e"i'ian 'ita ar+! "enent+'an (e!aran &ari n agar 9eng+%angann)a ti&a' ter%a%+ %a"a &an a!i%n)a $+'+9 (ai'. In9+t &ari "et#&e integra!i "#nte $ar%# ter!e(+t a&a%a (ata! (aa< (ata! ata!< (an)a'n)a 9eng+%angan.
Latihan '
Da%a" %atian 'a%i ini 'ita a'an "e"(+at !e(+a 9r#gra" +nt+' "engit+ng ni%ai &i!tri(+!i '+"+%ati4 &ari Di!tri(+!i N#r"a% Ba'+ &engan r+"+! !e(agai (eri'+t
∫ 1 e −∞ √ π
P ( E ≤ )=
1
− 5
d5
Agar 9er!a"aan &iata! &a9at &iit+ng 'ita a'an "engi%ang'an +n!+r 0b &engan "e"(agi "en,a&i &+a (agian !e9erti 9er!a"aan (eri'+t ini 1. 7i'a ni%ai X / "a'a /
1
− 5
∫ 1 e −∞ √ π
P ( E ≤ F )=
F
1
− 5
∫ √ 1 π e
d5 +
d5
/
1
− 5
∫ √ 1 π e
P ( E ≤ )=/.5 +
d5
/
. 7i'a ni%ai ` / "a'a /
∫
P ( E > )=
/
1
∫ √ 1 π e
P ( E > F )=
∞
1
∫
1 e− 5 d5 + 1 e− 5 d5 √π / √ π 1
− 5
d5 + /.5
F
P ( E ≤ F )= 1− P ( E > F ) Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 143
Modul Pemrograman Komputer /
1
− 5
∫ √ 1 π e
P ( E ≤ )=/.5−
d5
B+at%a !e(+a 4#r" &engan &e!ain !e(agai (eri'+t
Ke"+&ian at+r 9r#9ertie!n)a !e(agai (eri'+t omponen
Properties
Ial!e
B+tt#n1
Ca9ti#n
Hit+ng
La(e%1
Ca9ti#n
La(e%
Ca9ti#n
P2 `
E&it1
Tet
/
E&it
Tet
/.5
?
Ta"(a'an '#&e (eri'+t &i e&it#r !ete%a i"9%e"entati#n
proced!re distnormal7;real6/ar p;real96 /ar i1n;integer6 hasil;real6 begin n;<%======6 hasil;<=6 for i;< % to n do hasil;
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 144
Modul Pemrograman Komputer else p;< =.G ep7)=.G0ln7&0pi990n0hasil6 end6
K%i' &+a 'a%i 9a&a (+tt#n1 &an ta"(a'an '#&e (eri'+t &i e&it#r
proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar 1p;real6 begin ;
Ma'a a9a(i%a 9r#gra" &ie'!e'+!i a'an "engaa!i%'an !e(agai (eri'+t
D. (oal)soal %. B+at
9r#gra"
+nt+'
"engit+ng
;arian!
&an
'+rt#!i!
&engan
"engg+na'an 4+ng!i !tati!ti' 9a&a Laar+! Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 145
Modul Pemrograman Komputer &. B+at%a !e(+a 9r#gra" +nt+' "engit+ng 4+ng!i 9e%+ang '+"+%ati4 &ari
&i!tri(+!i i9erge#"etri' !e(agai (eri'+t
− ( )( − ) ≤ )=∑ ( ) 5
P(4
5
) =/
Bertho Tantular Jurusan Statistika FMIPA UNPAD
D 5
9 D n 5 9 n
Hal 14
Modul Pemrograman Komputer
MODUL % MEMBUAT DIAGRAM
PENDAHULUAN
Da%a" "#&+% ini a'an &i9e%a,ari "engenai (agai"ana "e"(+at &iagra" &i &a%a" Laar+!. Se(agai (aa!a 9e"r#gra"an ;i!+a% tent+n)a Laar+! ,+ga "en)erta'an !e,+"%a 4+ng!i +nt+' "e"(+at gra4i'. M#&+% ini ter&iri &ari &+a (agian )ait+ 9a&a (agian 9erta"a "engenai "e"(+at &iagra" (atang "engg+na'an 4+ng!i (ar$art. Se&ang'an 9a&a (agian 'e&+a a&a%a "engg+na'an 4+ng!i Cart +nt+' "e"(+at (er(agai ,eni! &iagra". Da%a" !tati!ti' &e!'ri9ti4 &iagra" )ang &ig+na'an (ia!an)a &iagra" (atang< &iagra" %ing'aran &an &iagra" gari!. Ketiga ,eni! &iagra" ini te%a &i!e&ia'an &i&a%a" 4+ng!i Cart.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 14!
Modul Pemrograman Komputer
Bagian 1 DIAGRAM BATANG
A. BarChart
K#"9#nen BarCart (erg+na +nt+' "e"(+at &iagra" (atang &a%a" Laar+!. Dengan
"engg+na'an
'#"9#nen
ini<
9en)a,ian
gra4i'
(er&a!ar'an
!e'+"9+%an &ata &a9at &i%a'+'an &engan "+&a. K#"9#nen BarCart ter&a9at 9a&a a% a"an Mi!$ 9a&a C#"9#nent Pa%ett e.
Latihan %
Da%a" %atian 'a%i ini 'ita a'an "e"(+at &iagra" (atang "engg+na'an 4+ng!i Bar$art. Unt+' it+ (+at%a 4#r" &engan ta"9i%an !e(agai (eri'+t
Ke"+&ian at+r 9r#9ertie!n)a !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 14"
Modul Pemrograman Komputer omponen
Properties
Ial!e
B+tt#n1
Ca9ti#n
Bar Cart
E&it1
Tet
/
E&it
Tet
/
E&it3
Tet
/
E&it
Tet
/
E&it5
Tet
/
BarCart1
Ca9ti#n
Diagra"Batang
K%i' &+a 'a%i 9a&a (+tt#n1 &an "a!+''an '#&e !e(agai (eri'+t proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 begin BarChart%.AddBar7label%.caption1strtoint7edit%.tet91clKreen96 BarChart%.AddBar7label&.caption1strtoint7edit&.tet91clred96 BarChart%.AddBar7label'.caption1strtoint7edit'.tet91clred96 BarChart%.AddBar7label*.caption1strtoint7edit*.tet91clKreen96 BarChart%.AddBar7labelG.caption1strtoint7editG.tet91clKreen96 end6
Sete%a 9r#gra" &ie'!e'+!i "a'a a'an "+n$+% ta"9i%an !e9erti (eri'+t ini
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 14#
Modul Pemrograman Komputer
B. Soal-soal
B+at%a !e(+a 9r#gra" +nt+' "ena"9i%'an &iagra" (atang 9a&a &ata (eri'+t ini 8AHUN EN,(
%'
%*
%G
PADI
85/
-5
15/
7AGUNG
55
65
35/
KEDELAI
*5
*//
8*5
KENTANG
35/
5
865
P:"DU(,
KOPI 7UMLAH
Bertho Tantular Jurusan Statistika FMIPA UNPAD
-5
1//
85
1-5
5*5
35
Hal 15$
Modul Pemrograman Komputer
Bagian 1 FUNGSI CHART
A. Chart
K#"9#nen Cart (erg+na +nt+' "e"(+at (er(agai ,eni! &iag ra" !e9er ti Diagra" Gari!< Diagra" Ling'ara n &an Diagra" (atang &a%a" Laar+ !. Dengan "engg+na'an '#"9#nen ini< 9en)a,ian gra4i' (er&a!ar'an !e'+"9 +%an &ata &a9at &i%a'+'an &engan "+ &a. K#"9#nen Cart ter&a9at 9a&a a%a"an A&&iti#na% 9a&a C#"9#nent Pa%ette.
Latihan %
Da%a" %atian 'a%i ini 'ita a'an "e"(+at (er(agai &iagra" "engg+na 'an 4+ng!i Cart. Unt+' it+ (+at%a 4#r" &engan ta"9i%an !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 151
Modul Pemrograman Komputer Ke"+&ian at+r 9r#9ertie!n)a !e(agai (eri'+t omponen
Properties
Ial!e
B+tt#n1
Ca9ti#n
B+at Diagra"
B+tt#n1
Ca9ti#n
Ke%+ar
Stringgri&1
C#%$#+nt
R#C#+nt
8
Ra&i#B+tt#n1
Ca9ti#n
Diagra"Batang
Ra&i#B+tt#n1 Ra&i#B+tt#n1
Ca9ti#n Ca9ti#n
Diagra"Pa!te% Diagra"Gari!
Cart
Ta"(a'an (e(era9a a% &i&a%a" (agian aa% +nit !ses Classes1 (ysUtils1 ileUtil1 L:eso!rces1 orms1 Controls1 Kraphics1 Dialogs1 Krids1 EtCtrls1 (tdCtrls1 8AKraph1 8A(eries1 B!ttons6
type 4 8orm% 5 8orm% < class78orm9 BitBtn%; 8BitBtn6 B!tton%; 8B!tton6 Chart%; 8Chart6 Kro!pBo%; 8Kro!pBo6 :adioB!tton%; 8:adioB!tton6 :adioB!tton&; 8:adioB!tton6 :adioB!tton'; 8:adioB!tton6 (tringKrid%; 8(tringKrid6 proced!re BitBtn%Click7(ender; 8"b#ect96 proced!re B!tton%Click7(ender; 8"b#ect96 pri/ate
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 152
Modul Pemrograman Komputer b; 8Bar(eries6 s; 8(erie6 p; 8Pie(eries6 p!blic 4 p!blic declarations 5 end6
K%i' &+a 'a%i 9a&a (+tt#n1 &an "a!+''an '#&e !e(agai (eri'+t proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar ;array%..F of integer6 banyak;array%..F of real6 i1n;integer6 begin chart%.6 chart%.BottomAis.Iisible;<8:UE6 chart%.LeftAis.Iisible;<8:UE6 n;
Hal 153
Modul Pemrograman Komputer for i;<% to n do p.AddPie7banyaki1inttostr7i91cl8Acolor96 end else if radiob!tton%.Checked then begin b ;< 8Bar(eries.Create7Chart%96 Chart%.Add(erie7b96 b.Bar?idthPercent;<%==6 for i;<% to n do b.AddSM7i1banyaki1OO1clred96 end else begin s;< 8(erie.Create7Chart%96 s.(ho$Lines ;< tr!e6 s.(ho$Points ;< tr!e6 s.Pointer.(tyle ;< ps:ectangle6 s.title ;< OlineO6 s.(eriesColor ;< cl:ed6 Chart%.Add(erie7s96 for i;<% to n do s.AddSM7i1banyaki1OO1clred96 end6 end6
K%i' &+a 'a%i 9a&a (+tt#n &an "a!+''an '#&e !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 154
Modul Pemrograman Komputer proced!re 8orm%.BitBtn%Click7(ender; 8"b#ect96 begin close6 end6
Sete%a 9r#gra" &ie'!e'+!i "a'a a'an "+n$+% ta"9i%an !e9erti (eri'+t ini
Unt+' Diagra" Batang
Unt+' Diagra" Ling'aran
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 155
Modul Pemrograman Komputer
Unt+' Diagra" Gari!
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 15
Modul Pemrograman Komputer B. (oal)soal
B+at%a !e(+a 9r#gra" +nt+' "ena"9i%'an &iagra" %ing'aran &an &iagra" (atang 9a&a &ata (eri'+t ini (ekolah
Banyak (is$a
SD
156
SLTP
1/-1
SLTA
86
PT
35
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 15!
Modul Pemrograman Komputer
MODUL & MENGAKSES BERKAS DAN PESAN KESALAHAN
PENDAHULUAN
Da%a" "#&+% ini a'an &i9e%a,ari "engenai $ara "enga'!e! (er'a! "e%a%+i Laar+! &an "ene"+'an &an "e"9er(ai'i 'e!a%aan "e%a%+ 9e!an 'e!a%aan ata+ messages. M#&+% ini ter&iri ata! &+a (agian )ait+ 9a&a (agian 9erta"a "engenai "enga'!e! (er'a! )ang "e%i9+ti $ara0$ara "e"(+at (er'a!< "en)i"9an (er'a!< &an "e"(+'a 'e"(a%i (er'a! )ang te%a &i!i"9an. Pa&a (agian 'e&+a &i,e%a!'an "engenai $ara "ene"+'an 'e!a%aan< "enent+'an ,eni! 'e!a%aan &an "e"9er(ai'i 9r#gra" )ang "engan&+ng 'e!a%aan. Di&a%a" Laar+! a9a(i%a 'ita "en+%i! !+at+ 9r#gra" &an tern)ata &ari !+!+nan ata+9+n !)nta )ang &ig+na'an ti&a' (enar "a'a a'an "+n$+% 9e!an 'e!a%aan error &i ,en&e%a -essages. Da%a" (agian ini 'ita a'an g+na'an 9e!an ini +nt+' "e"9er(ai'i 9r#gra" )ang 'ita (+at.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 15"
Modul Pemrograman Komputer
Bagian 1 MENGAKSES BERKAS
A. -engakses Berkas
Data )ang 'ita "i%i'i !e%a%+ 'ita !i"9an &a%a" !+at+ (er'a!. Ber(agai ,eni! (er'a! &i9erg+na'an +nt+' &ata &engan 'e%e(ian &an 'e'+ranggann)a "a!ing0"a!ing. Pe"i%ian ,eni! (er'a! (ia!an)a &i'ait'an &engan 'e$e9atan a'!e!< 'e"+&aan &a%a" 9en)i"9anan &an +'+ran "e"#ri )ang &ig+na'an. Ber'a! &i9erg+na'an +nt+' "e)i"9an &ata (ia!an)a &a%a" (ent+' 4i%e< &a%a" (aa!a 9e"#gra"an Laar+! (er'a! &i(agi "en,a&i 1. Ber'a! (erti9e . Ber'a! te'! 3. Ber'a! ta'0(erti9e Ber'a! (erti9e a&a%a (er'a! )ang &atan)a "e"i%i'i ti9e. Dengan "engg+na'an (er'a! (erti9e 'ita (i!a "e)i"9an &ata )ang (erti9e !e9erti rea%< integer &an (a'an )ang (er+9a !tr+'t+r &ata !e9erti record. Be(era9a 9r#!e&+r )ang &i9erg+na'an &a%a" "e)i"9an (er'a! (erti9e a&a%a
Nama Prosed!r
Pr#!e&+re A!!ignFi%e;ar FFi%eNa"e!tring
eg!naan
Unt+' "engait'an ;aria(e% (er'a! &engan na"a 4i!i' (er'a! Contoh
A!!ignFi%e=ar(er'a!<ABC.&at Rerite=aria(e%Ber'a!
Men$i9ta'an (er'a! &an "e"(+'an)a
Re!et=aria(e%Ber'a!
Me"(+'a(er'a!
C%#!eFi%e=aria(e%Ber'a!
Men+t+9(er'a!
rite=aria(e%Ber'a!<=aria(e%Data<...
Men)i"9an !e(+a record &ata
Rea&=aria(e%Ber'a!<
Me"(a$a&ata
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 15#
Modul Pemrograman Komputer
Latihan %
Da%a" %atian 'a%i ini 'ita a'an "e"(+at !e(+a 9r#gra" +nt+' "e"(+'a &an "en)i"9an 4i%e &a%a" (ent+' te'!. B+at%a F#r" &engan ta"9i%an !e(agai (eri'+t
omponen
Properties
Ial!e
B+tt#n1
Ca9ti#n
cSi"9an
B+tt#n
Ca9ti#n
cB+'a
E&it1
Tet
E&it
Tet
La(e%1
Ca9ti#n
Na"a
La(e%
Ca9ti#n
NPM
Me"#1
Line!
Pa&a 4#r" &i(aa 'ata type 'eti'%a '#&e (eri'+t ini
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1$
Modul Pemrograman Komputer 8(is$a < :ecord Nama;string'=6 NP-;string'=6 end6
pri/ate 4 Pri/ate declarations 5 Berkas(is$a; file of 8(is$a6 8erb!ka;Boolean6
K%i' &+a 'a%i 9a&a (+tt#n1 &an "a!+''an '#&e !e(agai (eri'+t proced!re 8orm%.B!tton%Click7(ender; 8"b#ect96 /ar NamaBerkas;string6 Data(is$a;8(is$a6 begin NamaBerkas;<3sis$a.dat36 assignile7Berkas(is$a1NamaBerkas96 if ileEists7NamaBerkas9 then :eset7Berkas(is$a9 else :e$rite7Berkas(is$a96 seek7Berkas(is$a1ile(i+e7Berkas(is$a996 ?ith Data(is$a do begin Nama;
Hal 11
Modul Pemrograman Komputer $rite7Berkas(is$a1Data(is$a96 Edit%.8et;
K%i' &+a 'a%i 9a&a (+tt#n &an "a!+''an '#&e !e(agai (eri'+t proced!re 8orm%.B!tton&Click7(ender; 8"b#ect96 Iar NamaBerkas;string6 Data;8(is$a6 begin NamaBerkas;
Hal 12
Modul Pemrograman Komputer read7Berkas(is$a1Data96 memo%.Lines.Add7data.Nama96 memo%.Lines.Add7data.NP-96 end6 end6
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 13
Modul Pemrograman Komputer
Bagian 2 MENEMUKAN PESAN KESALAHAN
A. Pesan esalahan
Di&a%a" Laar+! a9a(i%a 'ita "en+%i! !+at+ 9r#gra" &an tern)ata &ari !+!+nan ata+9+n !)nta )ang &ig+na'an ti&a' (enar "a'a a'an "+n$+% 9e!an 'e!a%aan error &i ,en&e%a -essages.
Se%ain 9e!an 'e!a%aan &a%a" ,en&e%a messages ,+ga &i(eri'an arning a9a(i%a a&a !e!+at+ 9a&a 9r#gra" 'ita &an 'eterangan a9a(i%a 9r#gra" 'ita te%a !+'!e!. Pa&a ga"(ar &iata! ter%iat (aa a&a 5 'e!a%aan )ang ter,a&i )ang &i t+n,+''an 9a&a !etia9 (ari! +nt+' !etia9 'e!a%aan. A9a(i%a 'ita '%i' 9a&a (ari! tertent+ &a%a" ,en&e%a "e!!age! "a'a !e$ara #t#"ati! &a%a" !#+r$e e&it#r "en+n,+''an (ari! )ang (eri!i 'e!a%aa )ang &i"a'!+&< !eingga 'ita (i!a &engan "+&a +nt+' "e"9er(ai'in)a. Beri'+t a'an &i,e%a!'an "engenai (e(era9a 9e!an 'e!a%aan )ang !ering "+n$+% &a%a" Laar+!
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 14
Modul Pemrograman Komputer %. "!t "f -emory
Me"#r) ta' $+'+9 +nt+' "e%a'+'an 9r#!e! "i!a%n)a "eng'#"9%i'a!i 'a%a+ !e&ang (era&a &a%a" IDE &ian,+r'an "eng'#"9%i'a!i 9r#gra" 'e &i!'.
&. ,dentifier Epected
Pengena% ;aria(%e &i9er%+'an 9a&a 9#!i!i )ang &it+n,+''an 'e"+ng'inan &i!e(a('an )ang &i9a'ai a&a%a re!er;e& #r& 'ata ter$a&ang.
'. Unkno$ ,dentifier
Pengena% ;aria(e% ata+ '#n!tanta (e%+" &i&e'%ara!i'an.
*. D!plikate ,dentifier
A&a 9engena% &engan na"a )ang !a"a.
G. (inta Error
A&a 'ara'ter )ang ti&a' &i9er'enan'an< (ia!an)a &i!e(a('an 'e'+rangan tan&a 9eti' 9a&a !tring.
@. Error ,n :eal Constant
Sa%a &a%a" 9en+%i!an '#n!tanta rea%.
F. Error ,n ,nteger Constant
Sa%a &a%a" 9en+%i!an '#n!tanta integer.
>. (tring Constant Ered Line
Sa%a 'arena !tring (e%+" &ia'iri &engan tan&a 9eti'.
. 8o -any -asted iles
Fi%e in$%+&e )ang "e"anggi% 4i%e in$%+&e 9er%+ &i'+rangi.
%=. Unepeted End "f ile
Bia!an)a &i!e(a('an !a%a 9en+%i!an Begin &an En& ata+ a&a !+at+ '#"entar )ang (e%+" &it+t+9.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 15
Modul Pemrograman Komputer %%. Line 8o Long
Pan,ang 'ara'ter &a%a" (ari! "e%e(ii 16 'ara'ter.
%&. 8ype ,dentifier Epected
Pengena% t)9e (e%+" &i(eri'an.
%'. 8oo -any "pen ile
Ter%a%+ (an)a' 4i%e )ang &i(+'a &a9at &iat+r "e%a%+i 4i%e CONFIG.S@S.
%*. ,nfalid ile Name
Na"a 4i%e !a%a.
%G. ile Not o!nd
Fi%e ti&a' &ite"+'an.
%@. Disk !ll
Di!' 9en+.
%F. ,nfalid Compiler Directi/e
Pengara $#"9+ter )ang &it+n,+''an ti&a' &i'ena%.
%>. 8oo -any iles
Ter%a%+ (an)a' 4i%e )ang &i%i(at'an !ea't+ "e%i(at'an '#"9%i'a!i +nit ata+ 9r#gra".
%. Undifined 8ype ,n Pointer Definition
T)9e )ang &ig+na'an 9a&a 9en&eni4i!ian 9#inter (e%+" &i&e'%ara!i'an.
&=. Iariable ,dentifier Epected
Pengena% )ang &it+n,+' !ear+!n)a "en)ata'an !e(+a ;aria(%e.
&%. Error ,n 8ype
Ke!a%aan &a%a" 9en&e4ini!ian t)9e.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1
Modul Pemrograman Komputer &&. (tr!ct!re 8oo Large
T)9e !tr+'t+r ter%a%+ (e!ar +'+ran "a'!i"a% )ang &i9er'enan'an )ait+ 655/ ()te.
&'. (et Base 8ype "!t "f :ange
T)9e &a!ar &ari i"9+nan ar+! (er(e&a &a%a" 'aa!an / !a"9ai 55 ata+ (er+9a t)9e en+"era!i )ang ,+"%a 'e"+ng'inann)a ti&a' %e(i &ari 56 (+a.
&*. ile Compotitions -y Not Be iles
K#"9#nen &ari 4i%e ti&a' (#%e (er+9a 4i%e.
&G. ,n/alid (tring Length
Pan,ang !tring &a%a" 9en&e'%ara!ian ar+!%a ter%eta' antara 1 !a"9ai 155.
&@. 8ype -ismach
T)9e ti&a' $#$#'.
&F. ,n/alid (!brange Base 8ype
Ke!a%aan 9a&a t)9e &a!ar !+(range.
&>. Lo$er Bo!nd Kreater 8han Upper Bo!nd
Da%a" "en&e'%ara!i'an !+(range< ni%ai aa% ar+! %e(i 'e$i% &ari9a&a ni%ai a'ir.
&. "rdinal 8ype Epected
T)9e )ang &i9er'ena%'an a&a%a t)9e #rigina%.
'=. ,nteger Constant Epected
Mengara9'an !+at+ '#n!tanta.
'%. Constant Epected
Mengara9'an !+at+ '#n!tanta.
'&. ,nteger "r :eal Constant Epected Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1!
Modul Pemrograman Komputer Mengara9'an '#n!tanta rea%:integer.
''. 8ype ,dentifier Epected
Mengara9'an 9engena% t)9e.
'*. ,nfalid !nction :es!lt 8ype
T)9e 'e%+aran 4+ng!i !a%a !ear+!n)a (er+9a t)9e !e&erana< !tring : 9#inter.
'G. Label ,dentifier Epected
Mengara9'an 9engena%an %a(e%.
'@. Begin Epected
K+rang Begin
'F. End Epected
K+rang En&.
'>. ,nteger Epression Epected
Mengaara9'an +ng'a9an integer.
'. "rdinal Epression Epected
Mengara9'an +ng'a9an #r&ina%.
*=. Boolean Epression Epected
Mengaara9'an +ng'a9an B##%ean.
*%. "perand 8ypes Do Not -atch "prator
T)9e #9eran& ti&' !e!+ai &engan #9erat#r.
*&. Error ,n Epression
Ke!a%aan &a%a" 9en+%i!an +nga'a9an .
*'. ,llegal Usignment
Ke!a%aan &a%a" 9ern)ataan 9en+ga!an. Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1"
Modul Pemrograman Komputer
**. ield ,dentifier Epected
Mengaara9'an 4ie%& &ari re$#r&.
*G. "b#ect ile 8oo Large
Fi%e #(,e$t )ang (er+'+ran %e(i &ari 6 '( ti&a' &a9at &i %in' #%e t+r(# 9a!$a%.
*@. Undefined Eternal
Pr#!e&+r : 4+ng!i e'!terna% (e%+" &i &e4ini!i'an.
*F. ,n/alid "b#ect ile :ecord
A&a !+at+ #(,e$t re$#r& &a%a" 4i%e #(,e$t )ang ti&a' !a.
*>. Code (egment 8oo Large
K#&e &a%a" !eg"ent '#&e ter%a%+ (e!ar 9r#!e&+r : 4+ng!i 9er%+ &i9e$a &a%a" (e(era9a +nit.
*. Data (egment 8oo Large
Data &a%a" !eg"en &ata ter%a%+ (e!ar te"9at'an &ata &a%a" ea9.
G=. Do Epected
K+rang D#.
G%. ,n/alid P!blic Definition
Ke!a%aan )ang (er'aitan &engan (aa!a a!!e"(%).
G&. ,n/alid Etrn Definition
Ke!a%aan )ang (er'aitan &engan (aa!a a!!e"(%).
G'. 8oo -any Etrn Definition
Ke!a%aan )ang (er'aitan &engan (aa!a a!!e"(%).
G*. "f Epected
K+rang O4. Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1#
Modul Pemrograman Komputer
GG. ,nterface Epected
K+rang Inter4a$e.
G@. ,n/alid :elocatable :eference
GF. 8hen Epected
K+rang Ten.
G>. 8o "r Do$n 8o Epected
K+rang T# ata+ D#nT#.
G. Underfined or$ard
De4ini!i &ari 9r#!e&+r : 4+ng!i (e%+" &i(eri'an.
@=. 8oo -any Proced!res
Ter%a%+ (an)a' 9r#!e&+r : 4+ng!i ,+"%a 4+ng!i.
@%. ,n/alid 8ypeCast
Ke!a%aan &a%a" "e%a'+'an t)9e$a!t '#n;er!i t)9e.
@&. Di/ision By Tero
Ke!a%aan 'arena 9e"(agian (i%angan &engan n#% /.
@'. ,n/alid ile 8ype
T)9e 4i%e )ang &ig+na'an ti&a' "engena% 9r#!e&+r . 4+ng!i 9enangan 4i%e )ang &it+n,+' "i!a%n)a 4i%e te'! ti&a' "engena% 9r#!e&+r !ee'.
@*. Cannot :ead "r ?rite Iariables "f 8his 8ype
T)9e &ari ;aria(%e )ang &it+n,+' ti&a' &a9at &i'ena%'an 9a&a in!tr+'!i rite &an rite%n ata+ Rea& &an Rea&%n.
@G. Pointer Iariable Epected
Mengaara9'an ;aria(%e 9#inter. Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1!$
Modul Pemrograman Komputer
@G. O6O Epected
K+rang titi' '#"a 9a&a a'ir (ari!.
B. Soal-soal
1. Perati'an 9r#gra" &i(aa ini ;ar i ()te (egin i/ i%e i X 01/ (egin %i!t(#1.ite"!.a&&i &e$i en& en& Te"+'an &an 9er(ai'i 'e!a%aan )ang a&a
. Te"+'an &an 9er(ai'i 'e!a%aan )ang a&a 9a&a 9r#gra" (eri'+t ini
Var i%a%r%n%S%Siinte$er) Snreal) 3e$in n/!trtoint4e#it1.te+t5) Si/6) 0or i/1 to n #o Si/Si728e+p44i-158ln4955) S/roun#4Si5) e#it2.te+t/intto!tr4S5) Sn/2841-e+p4n8ln49555:41-95) S/roun#4Sn5) Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1!1
Modul Pemrograman Komputer e#it9.Te+t/intto!tr4S5) en#)
3. Te%+!+ri (agian 9r#gra" (eri'+t ini /ar a1b1i1n;integer6 #!m%1#!m&1hasil;real6 begin a;
Pa&a (ari! "ana'a (agian 9r#gra" )ang !a%a err#r
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1!2
Modul Pemrograman Komputer
MODUL ' OBJECT ORIENTED PROGRAMMING
PENDAHULUAN
Da%a" "#&+% ini a'an &i9e%a,ari "engenai 9engertian Pe"r#gra"an (er#rienta!i #(,e' O(,e$t Oriente& Pr#gra""ing ata+ (ia!a &!ing'at OOP. M#&+% ini ter&iri ata! &+a (agian )ait+ 9a&a (agian 9erta" a "engenai "e"(+at +nit )ang ter&iri ata! 9engertian +nit &an 'e%a!< "ena"(a'an "et#&e &an 9engertian &e!tr+'t#r. Ha"9ir !e"+a 9erang'at %+na' $o#t(are 9enge"(angan a9%i'a!in)a "engara 9a&a 9e"#gra"an (er#rienta!i #(,e'. Ha% ini (erang'at &ari 'en)ataan (aa &engan "engg+na'an 9en&e'atan (er#rienta!i #(,e'<
!+at+ '#&e &a9at
&ig+na'an 'e"(a%i 9a&a !e,+"%a 9r#gra" &engan "+&a &a%a" 9e"#gra"an a% ini &i!e(+t reusability. A&a tiga 'ara'teri!ti' )ang "en&a!ari 9e"#gra"an (er#rienta!i #(,e' a Peng'a9!+%an Penge "a!an antara &ata &an 9r#! e&+r ata+ 4+ng !i &a%a" !at+ a&a )ang &i!e(+t #(,e'. ( Peari!an Ke"a"9+an !+at+ #(,e' +nt+' "en+r+n'an 'ara'teri!ti' )ang &i"i%i'in)a $ P#%i"#r4i!"e S+at+ !i4at )an g "e"+ng'in'an na"a )an g !a"a &a9a t "en)ata'an tin&a'an )ang (er(e&a. Pa&a (agian a'an &i(aa! tentang 9e"(+atan !#4tare !tati!ti'a )ang "e%i(at'an !e"+a 'ai&a0'ai&a &a%a" 9e"r#gra"an Laar+!< )ang te%a &i,e%a!'an 9a&a (a(0(a( !e(e%+"n)a. Pe"(+atan !#4tare !tati!ti'a )ang &i,e%a!'an 9a&a "#&+% ini &i(ata!i 9a&a 4+ng!i04+ng!i !tati!ti'a &a!ar )ang "e%i9+ti +'+ran 9e"+!atan< +'+ran %eta' &an +'+ran ;aria!i.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1!3
Modul Pemrograman Komputer
Bagian 1 MEMBUAT UNIT
A. "b#ek dan elas
Ke%a! 9a&a #(,e$t 9a!$a% ti&a' %ain a&a%a !+at+ ,eni! ti9e &ata ter!tr+'t+r. Ke%a! "en&e4ini!i'an !+at+ !tr+'t+r )ang ter!iri ata! 4ie%&< "et#&e &an 9r#9erti
a Fie%& =aria(e% )ang "er+9a'an (agian &ari 'e%a!< "iri9 0iel# 9a&a !tr+'t+r
reor# ( Met#&e S+(r+tin &a9at (er+9a 4+ng!i ata+ 9r#!e&+r $ Pr#9erti Fie%& )ang "e"i%i'i 9enent+ a'!e! (er+9a rea& &an rite
S+at+ 'e%a! &i&e'%ara!i'an &engan (ent+' !e(agai (eri'+t
8ype
Na"a'e%a!$%a!!'e%a!Orangt+a Da4tar Angg#ta End6
C#nt#
8ype
TStat&a!ar C%a!!
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1!4
Modul Pemrograman Komputer Rata rea% =arian! rea% End6
B. -enambah -etode
Fie%&04ie%& )ang (era&a 9a&a !+at+ 'e%a! +"+"n)a &ia'!e! "e%a%+i "et#&e. Me#&e 9a&a #(,e' (ia!an)a (er+9a 4+ng!i &an 9r#!e&+r ata+ '#n!tr+'t#r. K#n!tr+'t#r !en&iri a&a%a "et#&e '+!+ )ang "en$i9ta'an &an "e"(eri ni%ai aa% #(,e'. K#n!tr+'t#r &i$i9ta'an &enga 9erinta
C#n!tr+$t#r Create C#n!tr+$t#r Create9ara"eter
Latihan %
B+at%a !e(+a +nit &a%a" 9r#gra" &i(+ at &engan $ara "e"i%i File Ne(
;nit. Sa;e %a +nit )ang !+&a &i(+at &engan na"a (tatdasar %a%+ t+%i!'an '#&e (eri'+t ini
+nit Stat!
inter4a$e t)9e TStat! $%a!! 4+n$ti#n K=Srea%?rea%rea% en&
i"9%e"entati#n
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1!5
Modul Pemrograman Komputer 4+n$ti#n TStat!.K=SRea%?Rea%rea% (egin K=S:?1// en& en&.
Sete%a !+at+ 'e%a! &i&e'%ara!i'an< 'e%a! &a9at &ig+na'an +nt+' "en&e'%ara!i'an ;aria(e% 9a&a (agian =ar $#nt#
Iar
a!i%TStat!
Pa&a $#nt# &i ata!< a!i% "er+9a'an ;aria(e% )ang "en+n,+' 'e #(,e' )ang (er'e%a! 8(tatdasar. Pen&e'%ara!ian &i ata! ti&a' "en$i9ta'an #(,e'< +nt+' "en$i9ta'an #(,e'< &i 9erg+na'an 9erinta !e(agai (eri'+t
=aria(e%Na"a'e%a!.Na"aK#n!tr+'t+r Para"eter
C#nt#
a!i%TStat!.$reaterata<;arian!
Latihan &
Pa&a %atian (eri'+t 'ita a'an "e"(+at 9r#gra" +nt+' "engit+ng rata0rata< ;arian! &an '#"9enen ;aria!i K= "engg+na'an OOP. Unt+' it+ (+at%a !e(+a 4#r" &engan ta"9i%an !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1!
Modul Pemrograman Komputer
Ke"+&ian at+r 9r#9ertie!n)a !e(agai (eri'+t
omponen
Properties
Ial!e
E&it1
Tet
/
E&it
Tet
/
E&it3
Tet
/
B+tt#n1
Ca9ti#n
cHit+ng
Pa&a (agian aa% 9r#gra" ta"(a'an &a%a" +!e! +nit (tats.
!ses
in!< Me!!age!< S)!Uti%!< =ariant!< C%a!!e!<
Gra9i$!< C#ntr#%!<
F#r"!
Keti'an Stat&a!ar +nt+' "e"(erita+ (aa 9r#gra" )ang &i(+at "engg+na'an !nit (tats
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1!!
Modul Pemrograman Komputer K%i' &+a 'a%i 9a&a (+tt#n1 &an i!i'an '#&e !e(agai (eri'+t 9r#$e&+re TF#r"1.B+tt#n1C%i$'Sen&er TO(,e$t =ar a!i%TStat&a!ar rata<;arian!rea% (egin rata! trt#4%#ate&it1.Tet ;arian! !trt#4%#ate&it.Tet a!i%TStat!.$reate e&it3.Tet4%#att#!tra!i%.K=rata<;arian! en& en&.
C. Destr!ktor
De!tr+'t#r a&a%a "et#&e '+!+ 9a&a 'e%a! )ang (erg+na +nt+' "e%a'+'an 9e"(e(a!an "e"#ri (i%a #(,e' ti&a' &i9a'ai %agi. Bent+' "et#&e ini 9a&a 9rin!i9n)a !er+9a &engan '#n!tr+'t#r< &engan 'ata destr!ctor.
Destr!ctor De!tr#)
C#nt#
Ha!i%.&e!tr#)
D. Iisibilitas
Setia9 angg#ta 'e%a! "e"i%i'i ;i!i(i%ita!. =i!i(i%ita! "enent+'an (i!a ti&a'n)a !+at+ angg#ta 'e%a! &ia'!e! &i +nit %ain ata+ &a%a" !+at+ 9r#gra". C#nt#n)a
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1!"
Modul Pemrograman Komputer
Ha!i%.Rata Ha!i%.=arian! 1
Ha% &iata! "en+n,+''an (aa ;i!i(i%ita! 'e&+a 0iel# ter!e(+t (er&i4at pu3li &a9at &ia'!e! &ari "ana !a,a. =i !i(i%ita! angg#ta 'e%a! 4ie%& "a+9+n "et#&e &itent+'an "e%a%+i !a%a !at+ &iantara %i"a 'ata ter$a&ang !e(agai (eri'+t a Pri;ate Angg#ta 'e%a! ti&a' (i!a &ia'!e! &i %+ar +nit te"9at angg#ta &i&e'%ara!i'an. ( Pr#te$te& Angg#ta 'e%a! &a9at &ia'!e! 9a&a "#&+% te"9at 'e%a! &i&e'%ara!i'an !erta 9a&a 'e%a! t+r+nann)a. $ P+(%i$ Angg#ta 'e%a! &a9at &ia'!e! &ari "ana !a,a.
Latihan '
U(a%a '#&e 9a&a Latian 1 "en,a&i !e(agai (eri'+t +nit Stat! inter4a$e t)9e TStat! $%a!! 9r#te$te& 4+n$ti#n K=Srea%?rea%rea% en& i"9%e"entati#n 4+n$ti#n TStat!.K=SRea%?Rea%rea% (egin
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1!#
Modul Pemrograman Komputer K=S:?1// en& en&.
A9a'a 9r#gra" "a!i &a9at (er,a%an
E. Pe$arisan
Peari!an "en+n,+''an !+at+ 'e%a! "en+r+n'an 'ara'teri!ti' )ang &i"i%i'i 'e 'e%a! %ain. Ber'aitan &engan a% ini ter&a9at i!ti%a 'e%a!
#e!en#ant
&an 'e%a! ane!tor.
•
Ke%a! ane!tor a&a%a 'e%a! )ang "eari!'an 'ara'teri!ti' 'e 'e%a! %ain.
•
Ke%a! #e!en#ant a&a%a 'e%a! )ang "eari!'an 'ara'teri!ti' 'e 'e%a! %ain.
Latihan *
Ta"(a'an%a '#&e &i(aa implementation 9a&a +nit !tat! !e(agai (eri'+t
t)9e TM)Stat!$%a!!TStat! ::"e"(+at '%a! t+r+nan en&
. (oal)soal
1. B+at%a !e(+a 4+ng!i 9a&a +nit Stat! +nt+' "engit+ng '#e4i!ien 'e"iringan &engan r+"+! !e(agai (eri'+t
K#e4i!ien Ke"iringan =
− Do 4 $
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1"$
Modul Pemrograman Komputer Dengan
Rata0rata 4 Do M#&+!
$ Stan&ar De;ia!i . B+at%a !e(+a 'e% a! &engan na"a TM) Stat )ang "er+ 9a'an t+r+nan &ari 'e%a! TStat! &an "e"i%i'i 4+ng!i "engit+ng rata0rata +'+r &ari tiga (+a (i%angan !e(+t !a,a (i%angan ter!e(+t 4 1 < 4 &an 4 3 3. B+at%a !+at+ 4+ng!i 9a&a TM)Stat +nt+' "eng it+ng rata0rata it+ng &ari &ata 9enga"atan 4 1 < 4 <...< 4 n . B+at%a !e( +a 9r#gra" &e ngan a%g# rit"a Flo( chart +nt+' "eng+r+t'an &ata &engan $ara (+((%e !#rt !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1"1
Modul Pemrograman Komputer
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1"2
Modul Pemrograman Komputer
Bagian 2 MEMBUAT SOFT(ARE STATISTIKA
Da%a" (agian ini 'ita a'an "e"(+at !#4tare !tati!ti'a )ang "e%i(at'an !e"+a 'ai&a0'ai&a &a%a" 9e"r#gra"an Laar+!< &an "e"an4aat'an 9#t#ngan09#t#ngan 9r#gra" )ang te%a &i,e%a!'an 9a&a "#&+%0"#&+% !e(e%+"n)a. Pe"(+atan !#4tare !tati!ti'a )ang &i,e%a!'an 9a&a (agian ini &i(ata!i 9a&a 4+ng!i04+ng!i !tati!ti'a &a!ar )ang "e%i9+ti +'+ran 9e"+!atan< +'+ran %eta' &an +'+ran ;aria!i.
A. -emb!at elas
Se(agai %ang'a aa% a'an &i(+at !e(+a 'e%a! &engan na"a TMyStat! 9a&a +nit -yStat! !e(agai (eri'+t
!nit -y(tats6
interface type 8-y(tats < Class f!nction Ial-eans7S;array of real6n;integer9;real6 f!nction IalIariance7S;array of real6n;integer9;real6 end6 implementation f!nction 8-y(tats.Ial-eans7S;array of real6n;integer9;real6 /ar total;real6 i;integer6
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1"3
Modul Pemrograman Komputer begin total;<=6 for i;<% to n do begin total;
B. -emb!at -en! pada orm
Unt+'
"e"+&a'an
&a%a"
9eng#9era!ian
!e(+a
a9%i'a!i<
'ita
&a9at
"engg+na'an "en+ )ang +"+"n)a (era&a 9a&a (agian ata! F#r". Di&a%a" Laar+! 'ita (i!a "ena"(a'an "en+ &engan $ara !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1"4
Modul Pemrograman Komputer %. B+at%a !e(+a F#r" &. Ta"(a'an #(,e' -ain-en! 9a&a F#r"< te"9at'an !e"(arang. '. Pa&a ,en&e%a Pr#9ertie! +nt+' MainMen+ 9i%i ,tems "a'a a'an "+n$+%
,en&e%a (eri'+t
*. U(a Na"e "en,a&i Men+FI%e &an Ca9ti#n "en,a&i Fi%e< ,i'a ingin
"ena"(a'an +r+4 !#rt$+t ta"(a'an Ca9ti#n &engan tan&a c "en,a&i cFi%e G. K%i' 'anan 9a&a "en+ Fi%e &an 9i%i !+("en+< +(a 9r#9ertie! Na"e
"en,a&i Men+O9en &an Ca9ti#n "en,a&i cO9en 9a&a !+("en+ "en,a&i @. Ta"(a'an !+("en+ %ainn)a &an +(a 9r#9ertie! Na"e "en,a&i
Men+Sa;e &an Ca9ti#n "en,a&i cSa;e F. Ta"(a'an !+("en+ %ainn)a &an +(a 9r#9ertie! Na"e "en,a&i
Men+Eit &an Ca9ti#n "en,a&i Ecit. Ma'a ,en&e%a "en+ 'ita a'an "en,a&i !e9erti ini
Ma'a !e$ara #t#"ati! "en+ a'an "+n$+% &i!e(e%a 'iri ata! F#r". Kita &a9at "enga'!e! "en+ ter!e(+t &an a9a(i%a &i'%i' a'an "+n$+% e;ent '%i' &i &a%a" !#+r$e e&it#r.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1"5
Modul Pemrograman Komputer C. -endesain orm
Pa&a F#r"1 )ang te%a 'ita (+at ta&i ta"(a'an (e(era9a #(,e' )ait+ (tringKrid< -emo< (tat!sBar< (a/eDialog &an "penDialog< 'e"+&ian at+r%a
"engat+r 9r#9ertie! '#"9#nen )ang &i9erg+na'an !e(agai (eri'+t omponen
Properties
Ial!e
Stringgri&
Na"e
Gri&
Me"#
Na"e
Me"#1
Sa;eDia%#g
Na"e
Sa;eDia%#g1
O9enDia%#g
Na"e
O9enDia%#g1
MainMen+
Na"e
MainMen+1
Ite"!
O9enSa;eEit Ana%)eDe!$ri9ti;e Stati!ti$! He%9A(#+t
At+r%a O(,e' 9a&a F#r"1 !eingga "en,a&i !e9erti (eri'+t ini
Pin&a'an O3
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1"
Modul Pemrograman Komputer
Pa&a Ta( E;ent! 9a&a O3
proced!re 8orm%.ormCreate7(ender; 8"b#ect96 /ar i1#;integer6 begin for i;<% to form%.grid.:o$Co!nt do begin form%.grid.Cells=1i;
T+%i!%a &+a (+a 9r#!e&+r &i(aa ini &i(aa i"9%e"entati#n !e(agai (eri'+t Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1"!
Modul Pemrograman Komputer
proced!re (a/e(tringKrid7(tringKrid; 8(tringKrid6 const ileName; 8ileName96 /ar f;
8etile6
i1 k; ,nteger6 begin Assignile7f1 ileName96 :e$rite7f96 $ith (tringKrid do begin ?rite n!mber of Col!mns:o$s ?riteln7f1 ColCo!nt96 ?riteln7f1 :o$Co!nt96 loop thro!gh cells for i ;< = to ColCo!nt ) % do for k ;< = to :o$Co!nt ) % do ?riteln71 Cellsi1 k96 end6 Closeile796 end6
Load a 8(tringKrid from a file
proced!re Load(tringKrid7(tringKrid; 8(tringKrid6 const ileName; 8ileName96 /ar f;
8etile6
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1""
Modul Pemrograman Komputer i8mp1 i1 k; ,nteger6 str8emp;
(tring6
begin Assignile7f1 ileName96 :eset7f96 $ith (tringKrid do begin Ket n!mber of col!mns :eadln7f1 i8mp96 ColCo!nt ;< i8mp6 Ket n!mber of ro$s :eadln7f1 i8mp96 :o$Co!nt ;< i8mp6 loop thro!gh cells Y fill in /al!es for i ;< = to ColCo!nt ) % do for k ;< = to :o$Co!nt ) % do begin :eadln7f1 str8emp96 Cellsi1 k ;< str8emp6 end6 end6 Closeile7f96 end6
K%i' !at+ 'a%i 9a&a "en+ Fi%e 'e"+&ian 9i%i O9en &an t+%i!'an '#&e !e(agai (eri'+t
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1"#
Modul Pemrograman Komputer
proced!re 8orm%."pen%Click7(ender; 8"b#ect96 /ar Name;(tring6 begin if opendialog%.Eec!te then begin Name;<"pendialog%.ileName6 loadstringgrid7grid1Name96 end6 end6
K%i' !at+ 'a%i 9a&a "en+ Sa;e &an i!i'an '#&e !e(agai (eri'+t
proced!re 8orm%.(a/e%Click7(ender; 8"b#ect96 Iar Name;(tring6 begin if sa/edialog%.Eec!te then begin Name;
K%i' !at+ 'a%i 9a&a "en+ Eit &an i!i'an '#&e !e(agai (eri'+t Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1#$
Modul Pemrograman Komputer
proced!re 8orm%.Eit%Click7(ender; 8"b#ect96 begin close6 end6
D. orm (tatistika Deskriptif
Pa&a (agian !e(e%+"n)a 'ita te%a "e"i%i'i !e(+a F#r" )ang te%a (eri!i (er(agai "a$a" #(,e'< a'an teta9i +nt+' "e%a'+'an ana%i!i! 'ita "e"er%+'an ta"(aan F#r". B+at%a !e(+a 4#r" (ar+ &engan ta"9i%an !e(agai (eri'+t
Ke"+&ian at+r 9r#9ertie! !e(agai (eri'+t omponen
Properties
Ial!e
Li!t(#
Na"e
=ar%i!t
Li!t(#
Na"e
Li!t(#1
S9ee&(+tt#n
Ca9ti#n
XX
B+tt#n
Na"e
O'
B+tt#n
Ca9ti#n
Can$e%
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1#1
Modul Pemrograman Komputer Pa&a e;ent TForm2.FormS&o( t+%i!'an '#&e !e(agai (eri'+t proced!re 8orm&.orm(ho$7(ender; 8"b#ect96 /ar i1kolom ; integer6 begin IarList.Clear6 ListBo%.Clear6 kolom;
K%i' &+a 'a%i 9a&a t#"(#% Spee#utton1 9a&a F#r" &an i!i'an '#&e !e(agai (eri'+t
proced!re 8orm&.(peedB!tton%Click7(ender; 8"b#ect96 /ar inde1 i ; integer6 begin inde ;< IarList.,tems.Co!nt6 i ;< =6 $hile i W inde do begin if 7IarList.(electedi9 then begin ListBo%.,tems.Add7IarList.,tems.(tringsi96 IarList.,tems.Delete7i96 inde ;< inde ) %6 Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1#2
Modul Pemrograman Komputer i ;< =6 end else i ;< i %6 end6 end6
K%i' &+a 'a%i 9a&a t#"(#% utton1 9a&a F#r" &an i!i'an '#&e !e(agai (eri'+t proced!re 8orm&.B!tton%Click7(ender; 8"b#ect96 /ar i1#1noselected1kode;integer6 (elected;array of integer6 cellstring ;string6 S;array of real6 rata1/ariasi;real6 hasil;8-y(tats6 begin noselected ;< ListBo%.,tems.Co!nt6 (etLength7(elected1noselected96 Ket selected /ariables for i ;< % to noselected do begin cellstring ;< ListBo%.,tems.(tringsi)%6 for # ;< % to %== do if cellstring < form%.Krid.Cells#1= then selectedi)% ;< #6 end6 (etlength7S1form%.grid.:o$Co!nt)%96 form%.-emo%.Clear6 Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1#3
Modul Pemrograman Komputer for #;<% to noselected do begin for i;<% to form%.grid.:o$Co!nt)% do begin i)%;
IarOinttostr7#9O<
Ofloattostr7rata996 form%.-emo%.Lines.Add7OIarians floattostr7/ariasi996 form%.-emo%.Lines.Add7O
IarOinttostr7#9
O<
O
O96
hasil.Destroy6
Ke"+&ian e'!e'+!i 9r#gra"n)a &an a9a(i%a a&a 'e!a%aan !i%a'an &i9er(ai'i &an &i e'!e'+!i 'e"(a%i. Dari a!i% 9r#gra" )ang 'ita ,a%an'an 'ita &a9at "e%iat 'e'+rangan &ari 9r#gra" 'ita !eingga &a9at &i9er(ai'i +nt+' "en,a&i 9r#gra" )ang %e(i (ai'.
E. (oal)soal
Pa&a Pr#gra" )ang te%a &i(+at 9a&a "#&+% ini an)a "en)erta'an !e(+a ana%i!i! )ait+ Stati!ti'a De!'ri9ti4. M#&i4i'a!i 9r#gra" ter!e(+t &engan "ena"(a'an !+("en+ 9a&a "en+ ana%i!i! )ait+ %. Diagra"
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1#4
Modul Pemrograman Komputer &engan !+("en+ Diagra" Batang< Diagra" Ling'aran. Ke"+&ian (+at i!i'an '#&e0'#&en)a agar (i!a &ig+na'an. &. Peng+,ian Hi9#te!i! Rata0rata
&engan !+("en+ Sat+ !a"9e% 2< Sat+ !a"9e% t. Ke"+&ian (+at i!i'an '#&e0'#&en)a agar (i!a &ig+na'an.
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1#5
Modul Pemrograman Komputer
DAFTAR PUSTAKA
L+'it#< E&i"an 1--3 Be%a,ar Sen&iri Pe"r#gra"an &engan T+r(# Pa!$a% *./< PT E%e Me&ia K#"9+tin< 7a'arta. A(e% Aee"< M#ta /1 Start Pr#gra""ing U!ing O(,e$t Pa!$a% Free Pa!$a%:Laar+! B##'. E0(##' () M#ta A(e% Aee"< $#&e.!& 3/0/80/1. tt9::i&.i'i9e&ia.#rg:i'i:Laar+!Q^89erang'atQ%+na'^tt9::#"#9#re!t.(%#g!9#t.$#":/1:/:9e!an0err#r0&i09a!$a%0&an0$.t"%
Bertho Tantular Jurusan Statistika FMIPA UNPAD
Hal 1#