Chapter 13 Do It, Then Ask Permission (Posttest Loops) Clearly Visual Basic: Programming with Visual Basic 2010 2 nd Edition.

Slides:



Advertisements
Similar presentations
Chapter 2: Understanding Structure
Advertisements

Chapter 6: The Repetition Structure
Programming with Microsoft Visual Basic 2008 Fourth Edition
Programming with Microsoft Visual Basic th Edition
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program.
Introduction to Flowcharting
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 9 Decisions, Decisions, Decisions.
Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Published by Addison-Wesley.
Do/Loops A loop repeats a series of instructions. An iteration is a single execution of the statement(s) in the loop. Used when the exact number of iterations.
Chapter 2: Algorithm Discovery and Design
Do Loops A Do..Loop terminates based on a condition that is specified Execution of a Do..Loop continues while a condition is True or until a condition.
Chapter 2: Algorithm Discovery and Design
Chapter 61 Post Test Loop Do statement(s) Loop Until condition Loop is executed once and then the condition is tested. If it is False, the loop is run.
Chapter 5: More on the Selection Structure Programming with Microsoft Visual Basic.NET, Second Edition.
An Introduction to Programming with C++ Fifth Edition
An Introduction to Programming with C++ Fifth Edition Chapter 8 More on the Repetition Structure.
Chapter 5: Repetition Statements. In this chapter, you will learn about: Basic loop structures while loops Interactive while loops for loops Loop programming.
Repeating Program Instructions Chapter Microsoft Visual Basic.NET: Reloaded 1.
Chapter 2: Algorithm Discovery and Design
Chapter 2: Algorithm Discovery and Design
(C)opyright 2003 Scott/Jones Publishers Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Scott/Jones Publishers.
Microsoft Visual Basic 2008: Reloaded Fourth Edition
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Six Repeating Program Instructions.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Five More on the Selection Structure.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science, C++ Version, Third Edition.
Chapter 12: How Long Can This Go On?
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Seven More on the Repetition Structure.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter Five More on the Selection Structure.
1 Week 6 The Repetition Structure. 2 The Repetition Structure (Looping) Lesson A Objectives After completing this lesson, you will be able to:  Code.
Chapter 6: The Repetition Structure
Tutorial 51 Programming Structures Sequence - program instructions are processed, one after another, in the order in which they appear in the program Selection.
Tutorial 6 The Repetition Structure
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter Six The Do Loop and List Boxes.
Chapter 5: More on the Selection Structure Programming with Microsoft Visual Basic 2005, Third Edition.
C++ for Engineers and Scientists, Third Edition1 Objectives In this chapter, you will learn about: Basic loop structures while loops Interactive while.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 5: More on the Selection Structure
Programming with Microsoft Visual Basic th Edition
Computer Programming TCP1224 Chapter 8 More On Repetition Structure.
Introduction to Problem Solving and Control Statements.
Chapter 15 I’m on the Inside; You’re on the Outside (Nested Loops) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Advanced Repetition Structure and String Functions (Unit 10) Visual Basic for Applications.
7-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 16 I’m on the Inside; You’re on the Outside.
Tutorial 6: The Repetition Structure1 Tutorial 6 The Repetition Structure.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 13 How Long Can This Go On?
CSC 162 Visual Basic I Programming. Repetition Structures Pretest Loop –Exit condition is tested before the body of code is executed Posttest Loop –Exit.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission.
Chapter 27 Getting “Web-ified” (Web Applications) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Chapter 7: The Repetition Structure Introduction to Programming with C++ Fourth Edition.
Chapter 23 The String Section (String Manipulation) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Chapter 10 So Many Paths … So Little Time (Multiple-Alternative Selection Structures) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Chapter Five More on the Selection Structure Programming with Microsoft Visual Basic th Edition.
Chapter 7 What’s Wrong with It? (Syntax and Logic Errors) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Chapter 6 Controlling Program Flow with Looping Structures.
An Introduction to Programming with C++ Sixth Edition Chapter 8 More on the Repetition Structure.
Microsoft Visual Basic 2008: Reloaded Third Edition
Chapter 8: More on the Repetition Structure
Assigning a MyRepChat Phone Number
FIGURES FOR CHAPTER 1 GETTING STARTED
Clearly Visual Basic: Programming with Visual Basic nd Edition
Repeating Program Instructions
Microsoft Visual Basic 2005: Reloaded Second Edition
CIS 16 Application Development Programming with Visual Basic
Chapter 8: More on the Repetition Structure
Introduction to Problem Solving and Control Statements
Microsoft Visual Basic 2005: Reloaded Second Edition
Presentation transcript:

Chapter 13 Do It, Then Ask Permission (Posttest Loops) Clearly Visual Basic: Programming with Visual Basic nd Edition

Objectives Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 2 After studying Chapter 13, you should be able to: Show a posttest loop in both pseudocode and a flowchart Write a posttest loop using the Do…Loop statement

Testing After the Fact Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 3 Posttest loop Condition evaluated after loop instructions are processed Instructions in a pretest loop May never be processed Instructions in a posttest loop Will be processed at least once Figure 13-1 Shows the problem specification and algorithms

Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 4 Figure 13-1 Rob algorithms containing pretest and posttest loops

Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 5 Figure 13-2 Selection structure added to Algorithm 2 from Figure 13-1

More on the Do … Loop Statement Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 6 Pretest syntax The {While | Until} condition section Part of the Do clause Indicates that the condition is evaluated before the loop instructions are processed Posttest syntax The {While | Until} condition section Part of the Loop clause Indicates that the condition is evaluated after the loop instructions are processed

Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 7 Figure 13-3 Syntax and examples of the Do…Loop statement for a posttest loop

Pseudocode and Flowchart Containing a Posttest Loop Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 8 Figure 13-4 Shows the pseudocode and flowchart for Example 2 in Figure 13-3 The condition represented by the diamond Appears at the bottom of the loop in a posttest loop

Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 9 Figure 13-4 Pseudocode and flowchart for Example 2 in Figure 13-3

The Bouncing Robot Application Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 10 This application bounces a robot up and down on the form Number of bounces is entered in a text box Code and test the Bouncing Robot application Follow instructions on pages Then modify the Posttest Loop button’s code Follow instructions on page 236

Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 11 Figure 13-5 Selection structure added to the btnPosttest control’s Click event procedure

Summary Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 12 Instructions in a posttest loop Will be processed at least once Do…Loop statement Used to code a posttest loop in Visual Basic Condition can be phrased as either a looping condition or a loop exit condition Loop clause contains either: While keyword Until keyword