• Tidak ada hasil yang ditemukan

Adam Mukharil Bachtiar English Class Informatics Engineering 2011

N/A
N/A
Protected

Academic year: 2019

Membagikan "Adam Mukharil Bachtiar English Class Informatics Engineering 2011"

Copied!
55
0
0

Teks penuh

(1)

Adam Mukharil Bachtiar

English Class

Informatics Engineering 2011

Algorithms and Programming

(2)

Steps of the Day

Let’s Start

Definition of

Record

Application of

Record

Array of

Record

(3)

Definition of Record

(4)

Backg

round

of

R

ec

or

d

I need a program that

similar with array

program

but can be composed with

(5)

Wha

t

is R

ec

or

d

Data structure that contains of

several fields

(6)

Lecturer 1

Lecturer 2

NIP

Name

Address

NIP

Name

Address

Ilus

tr

a

tion

of R

ec

or

d

Records were named

Lecturer 1 and Lecture 2

,

consists of

3 fields

each of its.

Field

(7)

Lecturer 1

Lecturer 2

NIP

Name

Address

NIP

Name

Address

Ilus

tr

a

tion

of R

ec

or

d

Field

Name of Record

(8)

Application of Record

(9)

St

ep

s

in R

ec

or

d

Declare record

Initialize record

Accessing record (input, operate,

(10)

Record Declaration (Algorithm)

Kamus:

type

TipeRecord = record

< field_1 : TipeData_1,

field_2 : TipeData_2,

..

field_n :TipeData_n >

endrecord

(11)

Example of Record Declaration (Algorithm)

Kamus:

type

RecordDosen = record

< NIP : integer,

Nama : string,

Gaji : real >

endrecord

(12)

Record Declaration (PASCAL)

type

TipeRecord = record

field_1 : TipeData_1;

field_2 : TipeData_2;

..

field_n :TipeData_n;

end;

var

(13)

Example of Record Declaration (PASCAL)

type

RecordDosen = record

NIP : longint;

Nama : string;

Gaji : double;

end;

var

(14)

Record Initialization (Algorithm)

Format:

NamaRecord.NamaField

DefaultValue

Example:

Dosen.NIP

0

Dosen.Nama

‘’

(15)

Record Initialization (Pascal)

Format:

NamaRecord.NamaField := DefaultValue;

Example:

Dosen.NIP := 0;

Dosen.Nama := ‘’;

(16)

Input Value to Record (Algorithm)

Format:

input(NamaRecord.NamaField)

Example:

input(Dosen.NIP)

input(Dosen.Nama)

(17)

Input Value to Record (Pascal)

Format:

readln(NamaRecord.NamaField);

Example:

readln(Dosen.NIP);

readln(Dosen.Nama);

(18)

Output Value from Record (Algorithm)

Format:

output(NamaRecord.NamaField)

Example:

output(Dosen.NIP)

output(Dosen.Nama)

(19)

Output Value from Record (Pascal)

Format:

writeln(NamaRecord.NamaField);

Example:

writeln(Dosen.NIP);

writeln(Dosen.Nama);

(20)
(21)

Example of Record (Algorithm)

1 2 3 4 5 6 7 8 9 10 11 12 13 Algoritma RecordDosen

{I.S.: Dideklarasikan dua buah record dosen} {F.S.: Menampilkan isi record}

Kamus: type

RecordDosen = record < NIP : integer, Nama : string, Gaji : real > endrecord

(22)

Example of Record (Algorithm)

14 15 16 17 18 19 20 21 22 23 24 25 26 27 Algoritma: {input record} input(Dosen1.NIP) input(Dosen1.Nama) input(Dosen1.Gaji) input(Dosen2.NIP) input(Dosen2.Nama) input(Dosen2.Gaji)

{Operasi field record}

Dosen1.Gaji Dosen1.Gaji + 1000000 {Tambah THR}

(23)

Example of Record (Algorithm)

28 29 30 31 32 33 34 35

{Output record} output(Dosen1.NIP) output(Dosen1.Nama) output(Dosen1.Gaji)

(24)
(25)

Example of Record (Pascal)

14 15 16 17 18 19 20 21 22 23 24 25 26 27 {input record}

write('Masukkan NIP dosen pertama : '); readln(Dosen1.NIP);

write('Masukkan Nama dosen pertama : '); readln(Dosen1.Nama);

write('Masukkan Gaji dosen pertama : '); readln(Dosen1.Gaji);

writeln();

write('Masukkan NIP dosen kedua : '); readln(Dosen2.NIP);

write('Masukkan Nama dosen kedua : '); readln(Dosen2.Nama);

(26)

Example of Record (Pascal)

28 29 30 31 32 33 34 35 37 38 39 40 readln(Dosen2.Gaji);

{Operasi pada field record}

Dosen1.Gaji:=Dosen1.Gaji+1000000; {karena THR} Dosen2.Gaji:=Dosen2.Gaji-100000; {karena telat}

{output record} writeln();

writeln('NIP dosen pertama = ',Dosen1.NIP); writeln('Nama dosen pertama = ',Dosen1.Nama);

(27)

Example of Record (Pascal)

41 42 43 44 45 46 47 48 49

writeln();

writeln('NIP dosen kedua = ',Dosen2.NIP); writeln('Nama dosen kedua = ',Dosen2.Nama);

writeln('Gaji dosen kedua = ',Dosen2.Gaji:0:2);

writeln();

write('Tekan sembarag tombol untuk menutup...'); readkey();

(28)

Example of Record (Pascal)

54 55 56 57 58 59 60 61

jumlah2:=jumlah2+bil2[i]; end;

writeln('Jumlah elemen array bil 2 = ',jumlah2);

writeln();

write('Tekan sembarang tombol untuk menutup...'); readkey();

(29)

Array of Record

(30)

Backg

round

of

Arr

a

y

of R

ec

or

d

I have

lecturer’s record

but i need

lots of variables

to declare

(31)

Wha

t

is Ar

ra

y

of R

ec

or

d

Record that

declare

using

array’s form

.

It can be made using

all ways of array’s

(32)

[1]

[2]

NIP

Name

Address

NIP

Name

Address

Ilus

tr

a

tion

of A

rr

a

y

of R

ec

or

d

Had been declared an array that had

Lecturer

type

consists of

3 fields

each of element.

(33)

Array of Record Declaration (Algorithm)

Kamus:

const

maks = value

type

TipeRecord = record

< field_1 : TipeData_1,

field_2 : TipeData_2,

..

field_n : TipeData_n >

endrecord

NamaArrayofRecord = array [1..maks] of TipeRecord

(34)

Example of Array of Record Declaration (Algorithm)

Kamus:

const

maks = 20

type

DosenIF = record

< NIP : integer,

Nama : string,

Gaji : real >

endrecord

ArrayDosenIF = array [1..maks] of DosenIF

(35)

Array of Record Declaration (Pascal)

const

maks = value;

type

TipeRecord = record

field_1 : TipeData_1;

field_2 : TipeData_2;

..

field_n : TipeData_n;

end;

NamaArrayofRecord = array [1..maks] of TipeRecord;

var

(36)

Example of Array of Record Declaration (Pascal)

const

maks = 20;

type

DosenIF = record

NIP : longint;

Nama : string;

Gaji : double;

end;

ArrayDosenIF = array [1..maks] of DosenIF;

var

(37)

Record Initialization (Algorithm)

Format:

NamaRecord[indeks].NamaField

DefaultValue

Example:

Dosen[1].NIP

0

Dosen[1].Nama

‘’

(38)

Record Initialization (Pascal)

Format:

NamaRecord[indeks].NamaField := DefaultValue;

Example:

Dosen[1].NIP := 0;

Dosen[1].Nama := ‘’;

(39)

Input Value to Array of Record (Algorithm)

Format:

input(NamaRecord[indeks].NamaField)

Example:

input(Dosen[1].NIP)

input(Dosen[1].Nama)

(40)

Input Value to Array of Record (Pascal)

Format:

readln(NamaRecord[indeks].NamaField);

Example:

readln(Dosen[1].NIP);

readln(Dosen[1].Nama);

(41)

Output Value from Array from Record (Algorithm)

Format:

output(NamaRecord[indeks].NamaField)

Example:

output(Dosen[1].NIP)

output(Dosen[1].Nama)

(42)

Output Value from Array from Record (Pascal)

Format:

writeln(NamaRecord[indeks].NamaField);

Example:

writeln(Dosen[1].NIP);

writeln(Dosen[1].Nama);

(43)
(44)

Example of Array of Record (Algorithm)

1 2 3 4 5 6 7 8 9 10 11 12 13 Algoritma ArrayRecordMakananMinuman

{I.S : didefinisikan dua array of record food and drink} {F.S : menampilkan array of record beserta operasinya}

const

maks=3; type

(45)

Example of Array of Record (Algorithm)

14 15 16 17 18 19 20 21 22 23 24 25 26 27

RecordMinuman = record < KodeMinuman:integer, NamaMinuman:string, HargaMinuman:real, DiskonMinuman:real > endrecord

{array of record}

ArrayMakanan = array [1..maks] of RecordMakanan; ArrayMinuman = array [1..maks] of RecordMinuman;

Makanan:ArrayMakanan; Minuman:ArrayMinuman; TotalHarga:real;

(46)

Example of Array of Record (Algorithm)

28 29 30 31 32 33 34 35 37 38 39 40 41 42 Algoritma: {input record}

for i  1 to maks do

input(Makanan[i].KodeMakanan) input(Makanan[i].NamaMakanan); input(Makanan[i].HargaMakanan) input(Makanan[i].DiskonMakanan) endfor

for i 1 to maks do

(47)

Example of Array of Record (Algorithm)

43 44 45 46 47 48 49 50 51 52 53

{perhitungan total harga} TotalHarga  0

for i 1 to maks do

TotalHarga TotalHarga+(Makanan[i].HargaMakanan

(Makanan[i].HargaMakanan*Makanan[i].DiskonMakanan)) +(Minuman[i].HargaMinuman-

(Minuman[i].HargaMinuman*Minuman[i].DiskonMinuman)) endfor

{output record}

for i 1 to maks do

(48)

Example of Array of Record (Algorithm)

54 55 56 57 58 59 60 61

for i  1 to maks do

output(Minuman[i].KodeMinuman) output(Minuman[i].NamaMinuman) output(Minuman[i].HargaMinuman) output(Minuman[i].DiskonMinuman) endfor

(49)

Example of Array of Record (Pascal)

1 2 3 4 5 6 7 8 9 10 11 12 13 program MenuMakananMinuman; uses crt; const maks=3; type
(50)

Example of Array of Record (Pascal)

14 15 16 17 18 19 20 21 22 23 24 25 26 27

RecordMinuman = record KodeMinuman:integer; NamaMinuman:string; HargaMinuman:real; DiskonMinuman:real; end;

{array of record}

ArrayMakanan=array [1..maks] of RecordMakanan; ArrayMinuman=array [1..maks] of RecordMinuman; var

Makanan:ArrayMakanan; Minuman:ArrayMinuman; TotalHarga:real;

(51)

Example of Array of Record (Pascal)

28 29 30 31 32 33 34 35 37 38 39 40 41 begin {input record}

for i:=1 to maks do begin

write('Masukkan kode makanan ',i,' : '); readln(Makanan[i].KodeMakanan);

write('Masukkan nama makanan ',i,' : '); readln(Makanan[i].NamaMakanan);

write('Masukkan harga makanan ',i,' : '); readln(Makanan[i].HargaMakanan:0:2);

write('Masukkan diskon makanan ',i,' : '); readln(Makanan[i].DiskonMakanan:0:2);

(52)

Example of Array of Record (Pascal)

42 43 44 45 46 47 48 49 50 51 52 53 54 writeln();

for i:=1 to maks do begin

write('Masukkan kode Minuman ',i,' : '); readln(Minuman[i].KodeMinuman);

write('Masukkan nama Minuman ',i,' : '); readln(Minuman[i].NamaMinuman);

write('Masukkan harga Minuman ',i,' : '); readln(Minuman[i].HargaMinuman:0:2);

write('Masukkan diskon Minuman ',i,' : '); readln(Minuman[i].DiskonMinuman:0:2);

(53)

Example of Array of Record (Pascal)

55 56 57 58 59 60 61 62 63

{perhitungan total harga} TotalHarga:=0;

for i:=1 to maks do

TotalHarga:=TotalHarga+(Makanan[i].HargaMakanan (Makanan[i].HargaMakanan*Makanan[i].DiskonMakanan)) +(Minuman[i].HargaMinuman- (Minuman[i].HargaMinuman*Minuman[i].DiskonMinuman)); {output record} clrscr();

for i:=1 to maks do begin

(54)

Example of Array of Record (Pascal)

64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81

writeln('Harga makanan ',i,' adalah ',Makanan[i].HargaMakanan:0:2); writeln('Diskon makanan ',i,' adalah ',Makanan[i].DiskonMakanan:0:2); end;

writeln();

for i:=1 to maks do begin

writeln('Kode Minuman ',i,' adalah ',Minuman[i].KodeMinuman); writeln('Nama Minuman ',i,' adalah ',Minuman[i].NamaMinuman); writeln('Harga Minuman ',i,' adalah ',Minuman[i].HargaMinuman); writeln('Diskon Minuman ',i,' adalah ',Minuman[i].DiskonMinuman); end;

writeln();

writeln('Total harga yang harus dibayar adalah : Rp. ',TotalHarga:0:2); writeln();

write('Tekan sembarang tombol untuk menutup...'); readkey();

(55)

Contact Person:

Adam Mukharil Bachtiar Informatics Engineering UNIKOM Jalan Dipati Ukur Nomor. 112-114 Bandung 40132 Email: [email protected]

Blog: http://adfbipotter.wordpress.com

Referensi

Dokumen terkait

Penelitian ini bertujuan untuk mengetahui jenis dan biaya obat- obatan yang digunakan pasien yang berobat jalan dengan hipertensi di RSUP Haji Adam Malik Medan pada bulan Juli-

Therefore, the writer is interested in doing research to know the problems above with the research’s title “A STUDY ON TEACHING ENGLISH FOR SPECIFIC PURPOSES TO ENGINEERING CLASS OF

The purpose of this study was to obtain an overview of the evaluation of the learning outcomes of Leadership and Personal skills in 49 students of the Informatics

THE INFLUENCE OF KAHOOT IN READING SKILL OF INFORMATICS ENGINEERING STUDENTS AT POLITEKNIK SEKAYU A Thesis by BERTI ARTIKA SARI Student’s Number 1904410501.P English Education Study

Identifying Factors Affecting the Relationship between Department and Graduation Level of Informatics Engineering Students using Apriori Algorithm: A Case Study at Pamulang