Pemrograman VisualMinggu …5… Page 1 MINGGU Ke Lima Pemrograman Visual Pokok Bahasan: Control Statement II Tujuan Instruksional Khusus: Mahasiswa dapat.

Slides:



Advertisements
Similar presentations
Pemrograman VisualMinggu …6… Page 1 MINGGU Ke Enam Pemrograman Visual Pokok Bahasan: Module, Class & Methods Tujuan Instruksional Khusus: Mahasiswa dapat.
Advertisements

Pemrograman VisualMinggu …2… Page 1 MINGGU Ke Dua Pemrograman Visual Pokok Bahasan: Console Application Tujuan Instruksional Khusus: Mahasiswa dapat menjelaskan.
Pemrograman VisualMinggu …7… Page 1 MINGGU Ke Tujuh Pemrograman Visual Pokok Bahasan: Arrays Tujuan Instruksional Khusus: Mahasiswa dapat menjelaskan.
Pemrograman VisualMinggu …3… Page 1 MINGGU Ke Tiga Pemrograman Visual Pokok Bahasan: Class, Objects, Methods and Instance Variable Tujuan Instruksional.
Pemrograman VisualMinggu …12… Page 1 MINGGU Ke Duabelas Pemrograman Visual Pokok Bahasan: File and Stream Tujuan Instruksional Khusus: Mahasiswa dapat.
Pemrograman VisualMinggu …8… Page 1 MINGGU Ke Delapan Pemrograman Visual Pokok Bahasan: Graphical User Interface Tujuan Instruksional Khusus: Mahasiswa.
Pemrograman VisualMinggu …4… Page 1 MINGGU Ke Empat Pemrograman Visual Pokok Bahasan: Control Statement I Tujuan Instruksional Khusus: Mahasiswa dapat.
CS0004: Introduction to Programming Repetition – Do Loops.
Session 5 JavaScript/JScript: Control Structures II Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
1 10/20/08CS150 Introduction to Computer Science 1 do/while and Nested Loops Section 5.5 & 5.11.
 2006 Pearson Education, Inc. All rights reserved Control Statements: Part 2.
Iteration This week we will learn how to use iteration in C++ Iteration is the repetition of a statement or block of statements in a program. C++ has three.
Control Structures: Part 2. Introduction Essentials of Counter-Controlled Repetition For / Next Repetition Structure Examples Using the For / Next Structure.
1 Pertemuan 06 Repetition Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
Loops Repetition Statements. Repetition statements allow us to execute a statement multiple times Often they are referred to as loops Like conditional.
© 2004 Pearson Addison-Wesley. All rights reserved5-1 Iterations/ Loops The while Statement Other Repetition Statements.
Control Structures II. Why is Repetition Needed? There are many situations in which the same statements need to be executed several times. Example: Formulas.
Chapter 4: Control Structures II
Pemrograman VisualMinggu …12… Page 1 MINGGU Ke Duabelas Pemrograman Visual Pokok Bahasan: Exception Handling Tujuan Instruksional Khusus: Mahasiswa dapat.
Control Structures Session 03 Mata kuliah: M0874 – Programming II Tahun: 2010.
Pemrograman VisualMinggu …10… Page 1 MINGGU Ke Sepuluh Pemrograman Visual Pokok Bahasan: ADO.NET II Tujuan Instruksional Khusus: Mahasiswa dapat menjelaskan.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 9 - JavaScript: Control Statements II Outline 9.1 Introduction 9.2 Essentials of Counter-Controlled.
ENGR 112 Decision Structures.
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II UTPA – Fall
 2002 Prentice Hall. All rights reserved. 1 Chapter 5 – Control Structures: Part 2 Outline 5.1Introduction 5.2 Essentials of Counter-Controlled Repetition.
Problem Solving and Control Statements. Using Exit to Terminate Repetition Statements There are many forms of the Exit statement, designed to terminate.
Control Structures Week Introduction -Representation of the theory and principles of structured programming. Demonstration of for, while,do…whil.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Flow Control (Switch, do-while, break) Outline 4.7The.
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
Visual Basic.net Loops. Used to do multiple executions of the same block of code Do while loops Do until loops For next loops.
PROBLEM SOLVING WITH LOOPS Chapter 7. Concept of Repetition Structure Logic It is a computer task, that is used for Repeating a series of instructions.
JavaScript: Control Structures September 27, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel,
1 Chapter 10 Additional Control Structures and Exceptions.
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Flow Control (for) Outline 4.1Introduction 4.2The.
Control Structures II: Repetition.  Learn about repetition (looping) control structures  Explore how to construct and use count-controlled, sentinel-controlled,
CONTROL STATEMENTS LOOPS. WHY IS REPETITION NEEDED?  There are many situations in which the same statements need to be executed several times.  Example:
Think Possibility 1 Iterative Constructs ITERATION / LOOPS C provides three loop structures: the for-loop, the while-loop, and the do-while-loop. Each.
Higher Computing Software Development -So Far- 5/10/10.
CSC 162 Visual Basic I Programming. Repetition Structures Pretest Loop –Exit condition is tested before the body of code is executed Posttest Loop –Exit.
1 Microsoft® Visual Basic®.NET Language # 2. 2 Flow-Control Statements If … End If Select Case … End Select For… Next Do … Loop Exit.
5.1 Introduction Problem Solving –Requires understanding of: Building blocks Program-construction principles BZUPAGES.COM.
CONTROL STRUCTURE Chapter 3. CONTROL STRUCTURES ONE-WAY SELECTION Syntax: if (expression) statement Expression referred to as decision maker. Statement.
Lab 6 (1) Range Review, Control Logic and Loops ► Control Logic and Loops ► Exercise.
 2002 Prentice Hall. All rights reserved. 1 Chapter 5 – Control Structures: Part 2 Outline 5.1Introduction 5.2 Essentials of Counter-Controlled Repetition.
STRUCTURED PROGRAMMING Selection Statements. Content 2  Control structures  Types of selection statements  if single-selection statement  if..else.
Fourth Quarter.  Involves loops or cycles ◦ Loops: means that a process may be repeated as long as certain condition remains true or remains false. ◦
Java Programming: From Problem Analysis to Program Design, 4e Chapter 5 Control Structures II: Repetition.
Java Programming: From Problem Analysis to Program Design, 3e Chapter 5 Control Structures II: Repetition.
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2B) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
Repetition Statements b Repetition statements allow us to execute a statement multiple times repetitively b They are often simply referred to as loops.
Chapter 9 - JavaScript: Control Statements II
UNIT 5 Lesson 15 Looping.
Chapter 5- Control Structures: Part 2
Problem Solving and Control Statements: Part 2
Control Statements: Part 2
Control Structures: Part 2
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2B) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
Programming Fundamentals
Chapter 5 – Control Structures: Part 2
JavaScript: Control Statements (II)
The University of Texas Rio Grande Valley
The University of Texas – Pan American
Outline Altering flow of control Boolean expressions
حلقات التكرار.
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II – Exercises UTPA – Fall 2012 This set of slides is revised from.
Three Special Structures – Case, Do While, and Do Until
Intro to Programming Concepts
A LESSON IN LOOPING What is a loop?
CSCI 1100/1202 February 6, 2002.
Presentation transcript:

Pemrograman VisualMinggu …5… Page 1 MINGGU Ke Lima Pemrograman Visual Pokok Bahasan: Control Statement II Tujuan Instruksional Khusus: Mahasiswa dapat menjelaskan dan mengaplikasikan konsep control statement II pada Visual Basic 2008 Referensi: Deitel Deitel, Visual Basic 2008 (2009), How to Program, Prentice Hall. Chapter 6

Pemrograman VisualMinggu …5… Page 2 Agenda For... Next Repetition Statement Do... Loop while Repetition Statement Do... Loop Until Repetition Using Exit in Repetition Statements Using Continue in Repetition Statements Logical Operator

Pemrograman VisualMinggu …5… Page 3 For/Next Repetition Structure Statements For {kondisi awal} to {kondisi akhir} step value {numbers} Statements Next Statements

Pemrograman VisualMinggu …5… Page 4 Example of For Next Repetition Module modForCounter Sub Main() Dim counter As Integer For counter = 2 To 10 Step 2 Console.Write(counter & " ") Next Console.Readkey() End Sub End Module Result:

Pemrograman VisualMinggu …5… Page 5 Select Case Multiple-Selection Structure Select Case {variable} Case {value} Case {value awal} to {value akhir} Case {value}, {value awal} to {value akhir} End Select

Pemrograman VisualMinggu …5… Page 6 Example of Select Case Multiple-Structure Module Module1 Sub Main() Dim grade As Integer Console.Write("Masukan Total Nilai Akhir :") grade = Console.ReadLine() Select Case grade Case 100 Console.Write("Perfect") Case 85 To 99 Console.Write("Very Good") Case 75 To 84 Console.Write("Good") Case 65 To 74 Console.Write("Enough") Case 55 To 64 Console.Write("Bad") Case Else Console.Write("Very Bad") End Select End Sub End Module

Pemrograman VisualMinggu …5… Page 7 Do/Loop While Repetition Structure Statements Do Statements Loop While {kondisi} Statements The Do…Loop While Statement is similar to the Do While…Loop statement, except that the loop continuation Condition is tested after the loop body is performed; therefore, in a Do…Loop While statement, the loop body is always executed at least once.

Pemrograman VisualMinggu …5… Page 8 Example of Do/Loop While Repetition Module Module1 Sub Main() Dim counter As Integer = 1 Do Console.Write(counter & " ") counter += 1 Loop While counter <= 5 Console.Readkey() End Sub End Module Result:

Pemrograman VisualMinggu …5… Page 9 Do/Loop Until Repetition Structure Do Statements Loop Until {kondisi} Statements The Do…Loop until repetition statement is similar to the Do Until…Loop statement, except that the loop-termination condition is tested after the loop body is performed; therefore, the loop body executes at least once.

Pemrograman VisualMinggu …5… Page 10 Example of Do/Loop Until Repetition Module Module1 Sub Main() Dim counter As Integer = 1 Do Console.Write(counter & " ") counter += 1 Loop Until counter > 5 Console.Readkey() End Sub End Module Result:

Pemrograman VisualMinggu …5… Page 11 Using Exit in Repetition Statement The Exit Do Statement can be executed in a Do While…Loop, Do…Loop While, Do Until…Loop or Do…loop until statement, to cause the program to exit immediately from that repetition statement. The Exit For and Exit While statements cause immediate exit from For…Next and while …End While Loops, respectively

Pemrograman VisualMinggu …5… Page 12 Using the Exit Keyword in a Repetition Structure Exit For Exit Do Exit While Example: Module Module1 Sub Main() Dim counter As Integer = 1 Do Console.Write(counter & " ") counter += 1 If counter=3 Then exit do End If Loop While counter <= 5 Console.Readkey() End Sub End Module

Pemrograman VisualMinggu …5… Page 13 Logical Operators AndAlso expr1expr2Result FalseFalseFalse FalseTrueFalse TrueFalseFalse TrueTrueTrue OrElse expr1expr2Result FalseFalseFalse FalseTrueTrue TrueFalseTrue TrueTrueTrue

Pemrograman VisualMinggu …5… Page 14 Example of AndAlso & OrElse If age >=15 AndAlso age <= 40 Then Console.Write(“Usia Produktif”) Else Exit Do End If

Pemrograman VisualMinggu …5… Page 15 Questions & Answers

Pemrograman VisualMinggu …5… Page 16 Thank You