The Essence of Programming & Problem Solving · 2016-09-08 · The Essence of Programming & Problem...

13
9/8/2016 1 The Essence of Programming & Problem Solving TMB208 – Pemrograman Teknik Kredit: 3 (2-3) PROBLEM SOLVING Engineers must analyze and solve a wide range of technical problems. Some will be reasonably simple single- solution problems. Others will be open-ended and will likely require a team of engineers from several disciplines. Some problems may have no clear solution.

Transcript of The Essence of Programming & Problem Solving · 2016-09-08 · The Essence of Programming & Problem...

Page 1: The Essence of Programming & Problem Solving · 2016-09-08 · The Essence of Programming & Problem Solving TMB208 –Pemrograman Teknik Kredit: 3 ... instruksi komputer dengan rasional

9/8/2016

1

The Essence of Programming & Problem Solving

TMB208 – Pemrograman Teknik

Kredit: 3 (2-3)

PROBLEM SOLVING

• Engineers must analyze and solve a wide range of technical problems.

• Some will be reasonably simple single-solution problems.

• Others will be open-ended and will likely require a team of engineers from several disciplines. Some problems may have no clear solution.

Page 2: The Essence of Programming & Problem Solving · 2016-09-08 · The Essence of Programming & Problem Solving TMB208 –Pemrograman Teknik Kredit: 3 ... instruksi komputer dengan rasional

9/8/2016

2

PROBLEM SOLVING INVOLVES:•EXPERIENCE•KNOWLEDGE•PROCESS•ART

FOCUS: Computer Assisted Problem Solving

PROBLEM SOLVING

PROBLEM SOLVING

SOME SAY ENGINEERING PROBLEM SOLVING REQUIRES A COMBINATION OF SCIENCE AND ART:

SCIENCE

• Math

• Physics

• Chemistry

• Mechanics

• Etc.

ART

• Judgment

• Experience

• Common-Sense

• Know-How

• Etc.

Page 3: The Essence of Programming & Problem Solving · 2016-09-08 · The Essence of Programming & Problem Solving TMB208 –Pemrograman Teknik Kredit: 3 ... instruksi komputer dengan rasional

9/8/2016

3

THE ENGINEERING METHOD FOR PROBLEM SOLVING

• RECOGNIZE AND UNDERSTAND THE PROBLEM

• DETERMINE THE GOAL & SOLUTION

• GATHER DATA (AND VERIFY ITS ACCURACY)

• SELECT GUIDING THEORIES AND PRINCIPLES

• MAKE ASSUMPTIONS WHEN NECESSARY

• SOLVE THE PROBLEM

• VERIFY THE RESULTS

• PRESENT THE SOLUTION

Pemrograman Komputer

Pemrograman komputer adalah penulisansistematik yang berguna dan terpeliharaserangkaian instruksi dalam suatu bahasapemrograman untuk memerintahkancomputer melakukan suatu tugas tertentuyang diinginkan dengan benar

Page 4: The Essence of Programming & Problem Solving · 2016-09-08 · The Essence of Programming & Problem Solving TMB208 –Pemrograman Teknik Kredit: 3 ... instruksi komputer dengan rasional

9/8/2016

4

Bahasa Pemrograman

Bahasa pemrograman adalahbahasa formal yang dibuat dandirancang untuk memberi instruksiyang dapat dimengerti dandieksekusi oleh komputer

Contoh Bahasa pemrograman:(Visual Basic, FORTRAN, PHP, Pascal, Java, Dhelpi, Modula-2, PHP, C++)

To Know & Learn Programming

http://www.tutorialspoint.com/computer_programming/computer_programming_overview.htm

Page 5: The Essence of Programming & Problem Solving · 2016-09-08 · The Essence of Programming & Problem Solving TMB208 –Pemrograman Teknik Kredit: 3 ... instruksi komputer dengan rasional

9/8/2016

5

Programer

Programer adalah orang (satu tim) yang melakukan pekerjaanpemrograman komputer.

Syarat Programer

• Memiliki pengetahuan dan ketrampilanmenyelesaikan masalah tertentu

• Mengetahui cara dan metoda untuk memberiinstruksi komputer dengan rasional dan benar.

• Memiliki pengetahuan dan ketrampilanmenggunakan >= 1 bahasa pemrograman

• Memiliki pengetahuan dan ketrampilanmemvalidasi kebenaran program komputerdan merawatnya.

Page 6: The Essence of Programming & Problem Solving · 2016-09-08 · The Essence of Programming & Problem Solving TMB208 –Pemrograman Teknik Kredit: 3 ... instruksi komputer dengan rasional

9/8/2016

6

What is “Algorithm”?

• A formula or set of steps for solving a particular problem.

• It can be expressed in natural languages (e.g. English, Indonesia, Japanese, ...) or in programming languages (Visual Basic, FORTRAN, PHP, Pascal, PHP, C++)

• It has a set of inputs that must be transformed into a set of ouputs.

A Process View of An Algorithm• A process is depicted as a circle and has a

name

• A process is representing an algorithm that transforms a set of inputs into a set of ouputs

12

ABC -Program

A

B

C

X1

X2

A s

et

of

inp

uts

A s

et o

f o

utp

uts

Problem Example: Solving quadratic equation in the form of AX2+BX+C=0, where A, B,C are constants.

Page 7: The Essence of Programming & Problem Solving · 2016-09-08 · The Essence of Programming & Problem Solving TMB208 –Pemrograman Teknik Kredit: 3 ... instruksi komputer dengan rasional

9/8/2016

7

PROBLEM SOLVING EXAMPLE

Problem: Fill a bottle with stones

Instructions:

• Document any assumptions that may be required

• Write a step-by-step procedure for solving the problem

• Do this in pairs first then have a solution for your table

PROBLEM SOLVING EXAMPLE

Assumptions:

• Bottle is present

• Stones are present

• There are enough stones to fill bottle

• Bottle is empty (or at least not full)

• Some (or all) stones fit through opening

Page 8: The Essence of Programming & Problem Solving · 2016-09-08 · The Essence of Programming & Problem Solving TMB208 –Pemrograman Teknik Kredit: 3 ... instruksi komputer dengan rasional

9/8/2016

8

PROBLEM SOLVING EXAMPLE

Algorithm:

1. Set bottle upright near stones

2. Check to see if bottle is full. If so, then go to Step #6

3. Pick up a stone and try to put it in bottle

4. If stone too large to fit, discard stone, and go to Step #3

5. Otherwise, the stone fits, go to Step #2

6. Stop

PROBLEM SOLVING EXAMPLEProblem: Solving quadratic equation in the form of

AX2+BX+C=0, where A, B,C are constants.

Instructions:

• Document any assumptions that may be required

• Write a step-by-step procedure for solving the problem

• Do this in pairs first then have a solution for your table

ABC -Program

A

B

C

X1

X2A s

et o

f in

pu

ts

A s

et

of

ou

tpu

ts

Page 9: The Essence of Programming & Problem Solving · 2016-09-08 · The Essence of Programming & Problem Solving TMB208 –Pemrograman Teknik Kredit: 3 ... instruksi komputer dengan rasional

9/8/2016

9

PROBLEM SOLVING EXAMPLEAssumptions (Version 1):

• A ≠ 0, since it is a quadratic equation

• Solution of this quadratic equation problem is a set

of real numbers.

PROBLEM SOLVING EXAMPLE

Existing Analytical Solution Mathematical Solution:

Algorithm (versi 1):

1. Read the values of A, B & C

2. Compute D = B2 – 4AC .

3. Compute X1 = (-B + √D) / (2A)

4. Compute X2 = (-B - √D) / (2A)

5. Tampilkan X1, X2

5. Stop

Page 10: The Essence of Programming & Problem Solving · 2016-09-08 · The Essence of Programming & Problem Solving TMB208 –Pemrograman Teknik Kredit: 3 ... instruksi komputer dengan rasional

9/8/2016

10

PROBLEM SOLVING EXAMPLE

Assumptions (Versi 2):

• None (no assumptions)

PROBLEM SOLVING EXAMPLE

Algorithm (versi 2):1. Read the values of A, B & C2. If A = 0 then

2.1. Print “A can not be zero”2.2. Go to Step #8

3. Compute D = B2 – 4AC . 4. If D < 0 then

3.1. Print “There is not real solution”3.2. Go to Step #8

5. Compute X1 = (-B + √D) / (2A)6. Compute X2 = (-B - √D) / (2A)7. Print X1, X28. Stop

Page 11: The Essence of Programming & Problem Solving · 2016-09-08 · The Essence of Programming & Problem Solving TMB208 –Pemrograman Teknik Kredit: 3 ... instruksi komputer dengan rasional

9/8/2016

11

REQUIREMENT ANALYSIS

FUNCTIONAL REQUIREMENTS

• Based on the functions that must performed by the program.

• Question: “What tasks the system must be able to performed?”

NON-FUNCTIONAL REQUIREMENTS

• Based on program performance: accuracy, speed, reliability, ease of use, reliability

• Generally independent o the functional requirements

• Question: “How good the system can perform the required functions?”

EXAMPLE OF REQUIREMENT ANALYSIS:A case of problem of filling bottle with stones

Functional requirements

• Fill a bottle with stones until the bottle is fully filled.

Non-functional requirements

• Fill a bottle with stones as fast possible

• Sucessfully filling stones into the the bottle without falling down or breaking up the bottle.

Page 12: The Essence of Programming & Problem Solving · 2016-09-08 · The Essence of Programming & Problem Solving TMB208 –Pemrograman Teknik Kredit: 3 ... instruksi komputer dengan rasional

9/8/2016

12

EXAMPLE OF REQUIREMENT ANALYSIS:A case of solving a quadratic equation

Functional requirements

• Finding the value(s) of X that satisfies the equation AX2+BX+C=0 where the values of A, B & C are known.

Non-Functional requirements

• How fast the program can do the function?

• How reliable the program can perform the functions?

• How friendly the program can perform the functions?

EXAMPLE OF REQUIREMENT ANALYSIS:ATM Banking Program

Functional requirements

• Manjamin validitas kartu ATM

• Menjamin validitas nasabah

• Memberikan layanan untuk:

a. Melihat saldo

b. Mengambil uang tunai

c. Transfer uang

d. Membayar telepon & listrik

e. Menabung uang

f. Mencatat semua transaksi

g. Memberikan bukti transaksi

Non-Functional requirements

• Seberapa cepat sistem ATM dapat melayani fungsinya?

• Seberapa mudah (friendly) sistem ATM dapat digunakan?

• Seberapa handal keamananyang dapat diberikan?

• Seberapa luas jangkauan layanannya?

• Seberapa cepat waktu respon sistem ATMnya?

Page 13: The Essence of Programming & Problem Solving · 2016-09-08 · The Essence of Programming & Problem Solving TMB208 –Pemrograman Teknik Kredit: 3 ... instruksi komputer dengan rasional

9/8/2016

13

Assignment #1:Buatlah suatu algoritma untuk menghitung nilai R total dan arus Ir dari rangkaianlistrik berikut dengan benar tanpa error logic dan harus mengidentifikasi dahulu apainputnya dan apa ouput dari algoritma terlebih dahulu.

R1 R2

R3

R4

R5

+

Ir

Vs

Rtotal