9/8/2016
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 singlesolution problems. • Others will be open-ended and will likely require a team of engineers from several disciplines. Some problems may have no clear solution.
1
9/8/2016
PROBLEM SOLVING PROBLEM SOLVING INVOLVES: •EXPERIENCE •KNOWLEDGE •PROCESS •ART FOCUS: Computer Assisted Problem Solving
PROBLEM SOLVING SOME SAY ENGINEERING PROBLEM SOLVING REQUIRES A COMBINATION OF SCIENCE AND ART: SCIENCE
ART
• Math
• Judgment
• Physics
• Experience
• Chemistry
• Common-Sense
• Mechanics
• Know-How
• Etc.
• Etc.
2
9/8/2016
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 penulisan sistematik yang berguna dan terpelihara serangkaian instruksi dalam suatu bahasa pemrograman untuk memerintahkan computer melakukan suatu tugas tertentu yang diinginkan dengan benar
3
9/8/2016
Bahasa Pemrograman Bahasa pemrograman adalah bahasa formal yang dibuat dan dirancang untuk memberi instruksi yang dapat dimengerti dan dieksekusi oleh komputer Contoh Bahasa pemrograman: (Visual Basic, FORTRAN, PHP, Pascal, Java, Dhelpi, Modula-2, PHP, C++)
To Know & Learn Programming http://www.tutorialspoint.com/comput er_programming/computer_programmi ng_overview.htm
4
9/8/2016
Programer Programer adalah orang (satu tim) yang melakukan pekerjaan pemrograman komputer.
Syarat Programer • Memiliki pengetahuan dan ketrampilan menyelesaikan masalah tertentu • Mengetahui cara dan metoda untuk memberi instruksi komputer dengan rasional dan benar. • Memiliki pengetahuan dan ketrampilan menggunakan >= 1 bahasa pemrograman • Memiliki pengetahuan dan ketrampilan memvalidasi kebenaran program komputer dan merawatnya.
5
9/8/2016
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 Problem Example: Solving quadratic equation in the form of AX2+BX+C=0, where A, B,C are constants.
X1 B
ABC -Program X2
C
A set of outputs
A set of inputs
A
12
6
9/8/2016
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
7
9/8/2016
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 EXAMPLE Problem: Solving quadratic equation in the form of AX2+BX+C=0, where A, B,C are constants.
B C
X1 ABC -Program X2
A set of outputs
A set of inputs
A
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
8
9/8/2016
PROBLEM SOLVING EXAMPLE Assumptions (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
9
9/8/2016
PROBLEM SOLVING EXAMPLE Assumptions (Versi 2): • None (no assumptions)
PROBLEM SOLVING EXAMPLE Algorithm (versi 2): 1. Read the values of A, B & C 2. 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, X2 8. Stop
10
9/8/2016
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.
11
9/8/2016
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 keamanan yang dapat diberikan? • Seberapa luas jangkauan layanannya? • Seberapa cepat waktu respon sistem ATMnya?
12
9/8/2016
Assignment #1: Buatlah suatu algoritma untuk menghitung nilai R total dan arus Ir dari rangkaian listrik berikut dengan benar tanpa error logic dan harus mengidentifikasi dahulu apa inputnya dan apa ouput dari algoritma terlebih dahulu.
R1
Rtotal
R2
R4 R3 R5
Ir
+ Vs
13