Download presentation
Presentation is loading. Please wait.
Published byLauren Montgomery Modified over 9 years ago
1
Chapter 13 Do It, Then Ask Permission (Posttest Loops) Clearly Visual Basic: Programming with Visual Basic 2010 2 nd Edition
2
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
3
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
4
Clearly Visual Basic: Programming with Visual Basic 2010, 2 nd Edition 4 Figure 13-1 Rob algorithms containing pretest and posttest loops
5
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
6
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
7
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
8
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
9
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
10
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 235-236 Then modify the Posttest Loop button’s code Follow instructions on page 236
11
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
12
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.