konsep pemrograman oleh djoko luknantoluk.staff.ugm.ac.id/komputer/persamaankuadrat.pdf · blok...

Post on 19-Apr-2019

221 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Pemrograman Komputer

Konsep Pemrograman

olehDjoko Luknanto

Jumat, 02 Oktober 2015 http://luk.staff.ugm.ac.id/komputer 1

Konsep Pemrograman

outputprosesinput

2 0ax bx c

data algoritma+ program=

Jumat, 02 Oktober 2015 http://luk.staff.ugm.ac.id/komputer 2

Persamaan Kuadrat 1/2

• Input: data apa yang harus diinputkan?

2 0ax bx c

a b c

x1,2Jumat, 02 Oktober 2015 http://luk.staff.ugm.ac.id/komputer 3

Persamaan Kuadrat 2/2

21,2Jika 4 0,

2b DD b ac x

a

21,2Jika 4 0,

2b i DD b ac x

a

2 0ax bx c

Jumat, 02 Oktober 2015 http://luk.staff.ugm.ac.id/komputer 4

Microsoft Excel ‐Macro

Tunggal (sederhana)= if (test;

true‐block;

false‐block)

atau=if (test; true‐block; false‐block)

Jamak (bertingkat)= if (test;

if(test;true‐block;false‐block);

if(test;true‐block;false‐block))

Jumat, 02 Oktober 2015 http://luk.staff.ugm.ac.id/komputer 5

Contoh untuk Persamaan Kuadrat

• IF (a=0; “Persamaan Linier”; “Persamaan Kuadrat”)

• IF (a=0; “Persamaan Linier”; If(D=0; “Akar Kembar”; “Akar Beda”))

• IF (a=0; “Persamaan Linier”; If(D=0; “Akar Kembar”; if(D>0; “Akar Nyata”; “Akar imajiner”))

Jumat, 02 Oktober 2015 http://luk.staff.ugm.ac.id/komputer 6

Contoh untuk kasus a = 0

Jumat, 02 Oktober 2015 http://luk.staff.ugm.ac.id/komputer 7

Contoh untuk kasus a = 0 dan b = 0

Jumat, 02 Oktober 2015 http://luk.staff.ugm.ac.id/komputer 8

Contoh untuk kasus input berupa teks

Jumat, 02 Oktober 2015 http://luk.staff.ugm.ac.id/komputer 9

Contoh untuk kasus D > 0

Jumat, 02 Oktober 2015 http://luk.staff.ugm.ac.id/komputer 10

Contoh untuk kasus D = 0

Jumat, 02 Oktober 2015 http://luk.staff.ugm.ac.id/komputer 11

Contoh untuk kasus D < 0

Jumat, 02 Oktober 2015 http://luk.staff.ugm.ac.id/komputer 12

Fortran/BASICS

Tunggal (sederhana)IF (true) THEN

true‐blockELSE

false‐blockENDIF

Jamak (bertingkat)IF (true) THEN

true‐blockELSE IF (true) THEN

true‐blockELSE

false‐blockENDIF

Jumat, 02 Oktober 2015 http://luk.staff.ugm.ac.id/komputer 13

Blok Persamaan Linier

Blok Kontradiksi

Contoh Algoritma Persamaan Kuadrat

Jumat, 02 Oktober 2015 http://luk.staff.ugm.ac.id/komputer 14

Blok Persamaan Kuadrat

If A = 0.0 And B = 0.0 Then‘Tidak bisa dihitung karena kontradiksi! 

ElseIf A = 0.0 Then'Bukan persamaan kuadrat, tetapi linier

Else'Hitung DiskriminanDiskriminan = B * B ‐ 4 * A * CIf Diskriminan > 0 Then'Akar berbeda

ElseIf Diskriminan = 0 Then'Akar kembar

Else'Akar imajiner

End IfEnd If

Contoh Hasil VBA‐Excel

Jumat, 02 Oktober 2015 http://luk.staff.ugm.ac.id/komputer 15

top related