1 Pertemuan 05 Selection Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Advertisements

1 Pertemuan > > Matakuliah: >/ > Tahun: > Versi: >
Pertemuan 13 Threads Matakuliah: H0483 / Network Programming Tahun: 2005 Versi: 1.0.
1 Pertemuan 16 First & Second Conditionals Matakuliah: G0134 – Grammar III Tahun: 2005 Versi: revisi 1.
1 Pertemuan 12 Binary Search Tree Matakuliah: T0026/Struktur Data Tahun: 2005 Versi: 1/1.
1 Pertemuan 04 Proxy/Cache Matakuliah: H0491/Praktikum Jaringan Komputer Tahun: 2005 Versi: 1/0.
Pertemuan <<12>> Paralel dan Basis Data Terdistribusi
1 Pertemuan 22 Radix Sort Matakuliah: T0016/Algoritma dan Pemrograman Tahun: 2005 Versi: versi 2.
Dynamic SQL Pertemuan 11 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
12 - Organisation Matakuliah: G0622/Bahasa Inggris 1 Tahun: 2005 Versi: 1.01.
Lesson 5 - Decision Structure By: Dan Lunney
Pascal Programming Today Chapter 4 1 »Conditional statements allow the execution of one of a number of possible operations. »Conditional statements include:
Session 5 JavaScript/JScript: Control Structures II Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
1 Pertemuan 10 Arsitektur Jaringan Model OSI Matakuliah: H0174/Jaringan Komputer Tahun: 2006 Versi: 1/0.
1 Pertemuan 26 Object Relational Database Management System (Lanjutan) Matakuliah: M0174/OBJECT ORIENTED DATABASE Tahun: 2005 Versi: 1/0.
1 Pertemuan 23 Object database design (Lanjutan bagian 2) Matakuliah: M0174/OBJECT ORIENTED DATABASE Tahun: 2005 Versi: 1/0.
1 Pertemuan > > Matakuliah: >/ > Tahun: > Versi: >
1 Pertemuan 13 BACK PROPAGATION Matakuliah: H0434/Jaringan Syaraf Tiruan Tahun: 2005 Versi: 1.
1 Pertemuan 01 Algorithm Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
1 Pertemuan 24 Object database design (Lanjutan bagian 3) Matakuliah: M0174/OBJECT ORIENTED DATABASE Tahun: 2005 Versi: 1/0.
1 Pertemuan 14 Object Query Language (Lanjutan bagian 1) Matakuliah: M0174/OBJECT ORIENTED DATABASE Tahun: 2005 Versi: 1/0.
Embedded SQL Pertemuan 9 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
1 Pertemuan 14 Arsitektur Process Matakuliah: M0446/Analisa dan Perancangan Sistem Informasi Tahun: 2005 Versi: 0/0.
1 Pertemuan Pertama Introduction to Marketing Research Matakuliah: MN J0412/ Riset Pemasaran Tahun: 2007 Versi:
1 Pertemuan 04 Expression Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
07 - Advertising Matakuliah: G0622/Bahasa Inggris 1 Tahun: 2005 Versi: 1.01.
1 Pertemuan 9 Making an outline Matakuliah: G1072 – Reading 1 Tahun: 2005 Versi: revisi 0.
1 Pertemuan 21 Parallelism and Superscalar Matakuliah: H0344/Organisasi dan Arsitektur Komputer Tahun: 2005 Versi: 1/1.
1 Pertemuan 07 Procedures Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
1 Pertemuan 21 Audit Reporting Matakuliah:A0274/Pengelolaan Fungsi Audit Sistem Informasi Tahun: 2005 Versi: 1/1.
1 Pertemuan 17 Building Object Database Application Matakuliah: M0174/OBJECT ORIENTED DATABASE Tahun: 2005 Versi: 1/0.
1 Pertemuan 11 QUIZ Matakuliah: J0274/Akuntansi Manajemen Tahun: 2005 Versi: 01/00.
11 - Innovation Matakuliah: G0622/Bahasa Inggris 1 Tahun: 2005 Versi: 1.01.
1 Pertemuan 02 Visual Basic Environment and Control Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
1 Pertemuan 20 Time & Condition Clauses with Future reference Matakuliah: G0134 – Grammar III Tahun: 2005 Versi: revisi 1.
1 Pertemuan 09 Database Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
1 Pertemuan 18 I wish, If only Matakuliah: G0134 – Grammar III Tahun: 2005 Versi: revisi 1.
1 Pertemuan 7 The Object Definition Language Matakuliah: M0174/OBJECT ORIENTED DATABASE Tahun: 2005 Versi: 1/0.
1 Pertemuan #3 Clocks and Realtime Matakuliah: H0232/Sistem Waktu Nyata Tahun: 2005 Versi: 1/5.
1 Pertemuan 14 Phrases of agreement Matakuliah: G0134/Grammar III Tahun: 2005 Versi: revisi 1.
1 Pertemuan 9 JARINGAN LEARNING VECTOR QUANTIZATION Matakuliah: H0434/Jaringan Syaraf Tiruan Tahun: 2005 Versi: 1.
1 Pertemuan 06 Repetition Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
1 Pertemuan 03 Representing Data Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
1 Pertemuan 25 Parallel Processing 1 Matakuliah: H0344/Organisasi dan Arsitektur Komputer Tahun: 2005 Versi: 1/1.
13 - Organisation Matakuliah: G0622/Bahasa Inggris 1 Tahun: 2005 Versi: 1.01.
1 Pertemuan 10 The Manipulative part of the object data model (Lanjutan bagian 1) Matakuliah: M0174/OBJECT ORIENTED DATABASE Tahun: 2005 Versi: 1/0.
1 Pertemuan 8 The Object Definition Language (Lanjutan) Matakuliah: M0174/OBJECT ORIENTED DATABASE Tahun: 2005 Versi: 1/0.
Lecture Set 5 Control Structures Part A - Decisions Structures.
Selection Structure If... Then.. Else Case. Selection Structure Use to make a decision or comparison and then, based on the result of that decision or.
1 Boolean Expressions to Make Comparisons Boolean expression –Represents only one of two states –Expression evaluates to either true or false Expressions.
1 Pertemuan 10 Deadlock (lanjutan) Matakuliah: T0316/sistem Operasi Tahun: 2005 Versi/Revisi: 5.
CHAPTER FIVE Specifying Alternate Courses of Action: Selection Statements.
1 Pertemuan 26 Making It Happen Matakuliah: A0194/Pengendalian Rekayasa Ulang Informasi Tahun: 2005 Versi: 1/5.
1 Pertemuan 25 Bahasa-bahasa Pemrograman Matakuliah: T0604-Pengantar Teknologi Informasi Tahun: 2008 Versi: 2.0/0.0 Williams, B.K, Stacy C. Sawyer (2007).
Control Flow Statements
Pertemuan 02 The Nature of Accounting and Information Technology Matakuliah: M0034 /Informasi dan Proses Bisnis Tahun: 2005 Versi: 01/05.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
C++ for Engineers and Scientists Second Edition Chapter 4 Selection Structures.
Pertemuan <<11>> <<HELP DESK (01) >>
Matakuliah : D0524 / Algoritma dan Pemrograman Komputer
Pertemuan 04 Proxy/Cache
Pertemuan 20 Building Object Database Application (Lanjutan bagian 3)
Pertemuan 12 Manajemen Memory (Lanjutan)
Pertemuan 22 The Business Views of the Technology Architecture
Chapter 5 Decisions. Chapter 5 Decisions ssential uestion: How are Boolean expressions or operators used in everyday life?
Pertemuan 11 Model TCP/IP
VBScript Session 4 Dani Vainstein.
Chapter 3: Introduction to Problem Solving and Control Statements
Visual Basic – Decision Statements
ICT Programming Lesson 3:
Presentation transcript:

1 Pertemuan 05 Selection Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:

2 Learning Outcomes Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : Mendemonstrasikan penggunaan perintah seleksi

3 Outline Materi The If…Then...Else Statement Nested If Statement The Select Case Statement

4 The If…Then...Else Statement The If…Then…Else statement enables a program to handle situations having two outcomes. The statement has three parts: 1.The condition. 2.The statements to perform for the first outcome. 3.The statements to perform for the second outcome. Syntax and Action of If…Then…Else –The If…Then…Else statement has the following syntax: If condition Then –Statementblock1 Else –Statementblock2 End If

5 The If…Then...Else Statement –Run Time: The Effect of the If…Then…Else Statement True: the computer executes the statements in statementblock1. False: the computer skips to Else and executes the statements in statementblock2. –Meta Statements Describe compound statement with a single phrase. –Problem Solving and Pseudocode Problem solving is the process of writing code to perform a required task. Pseudocode is an English-like outline of the logical for program code. –Ex. Request address from user Receive input in a textbox

6 The If…Then...Else Statement –Using Logical Expressions in If…Then…Else Statements The condition of an If…Then…Else statement may be a logical expression. –Ex. (YearsExperience>5) And (NumberOfLanguages>=3) –If…Then Sometimes only one of two outcomes requires processing. –If condition Then statementblock –End If

7 Nested If Statement If statements may contain one within another. If (X<Y) And (Y<Z) Then AscOrDesc = “ascending” Else If (X>Y) And (Y>Z) Then AscOrDesc = “descending” Else AscOrDesc = “neither ascending nor descending” End If

8 The Select Case Statement Can handle conditions with multiple outcomes. –Syntax and Action of Select Case Select Case testexpression Case expressionlist1 statementblock1 Case expressionlist2 statementblock2 … Case expressionlistN statementblockN Case Else statementblock End Select

9 The Select Case Statement –Run Time: The Effect of the Select Case Statement First the computer evaluates the test expression. Then it tries to match the resulting value. The search starts at the top expression list. The computer stops at the first match. The corresponding statement block is executed. Control resumes after the End Select. If no match occurs and a Case Else exists, then the Case Else block is executed. Then control resumes after the End Select. If no match occurs and no Case Else exists, then control resumes after the End Select. –Ranges Two variations –Use the keyword “To” »Ex. 25 To 37 –Use the keyword “Is” »Ex. Is >= 77

10 If versus Select Case If a decision has only two outcomes and the condition can be expressed as a single logical expression, then the If statement is easier to read. If a decision has multiple outcomes that depend on a single expression, then the Select Case is usually easier to read. If the outcomes depend on a number of conditions that may be independent, then embedded If statements are better.