tools for structured and object oriented design - do until structures

14
DO UNTIL Tools for Structured and Object-Oriented Design

Upload: andrew-carts

Post on 12-Apr-2016

40 views

Category:

Documents


1 download

DESCRIPTION

Tools for Structured and Object Oriented Design - DO UNTIL Structures

TRANSCRIPT

Page 1: Tools for Structured and Object Oriented Design - DO UNTIL Structures

DO UNTIL

Tools for Structured and Object-Oriented Design

Page 2: Tools for Structured and Object Oriented Design - DO UNTIL Structures

Objectives

• Indentify, and use in program design, the DO UNTIL control Structure

• Distinguish between the logic of a DOWHILE pattern and the logic of a DOUNTIL pattern.

Page 3: Tools for Structured and Object Oriented Design - DO UNTIL Structures

Using the Do Until Loop

• When you use either a while or a for loop, the body of the loop may never execute

• When you want to ensure that a loop’s body executes at least one time, you can use a do until loop

• In a do until loop, the loop control variable is evaluated after the loop body executes

• Therefore, the body always executes at least one time

Page 4: Tools for Structured and Object Oriented Design - DO UNTIL Structures

do until Loop for Producing One Extra Label

Page 5: Tools for Structured and Object Oriented Design - DO UNTIL Structures

Printing One Label, Then Printing Enough to Cover Production

Page 6: Tools for Structured and Object Oriented Design - DO UNTIL Structures

Recognizing the Characteristics Shared by All Loops• All structured loops share these characteristics:

– The loop-controlling question provides either entry to or exit from the repeating structure

– The loop-controlling questions provide the only entry to or exit from the repeating structure

• You should also notice the difference between unstructured loops and the structured do until and while loops

Page 7: Tools for Structured and Object Oriented Design - DO UNTIL Structures

DO UNTIL Example

Page 8: Tools for Structured and Object Oriented Design - DO UNTIL Structures

DO UNTIL Example

Page 9: Tools for Structured and Object Oriented Design - DO UNTIL Structures

DO UNTIL ExamplePseudocode

Page 10: Tools for Structured and Object Oriented Design - DO UNTIL Structures

DO UNTIL Example

Page 11: Tools for Structured and Object Oriented Design - DO UNTIL Structures

DO UNTIL Example

Page 12: Tools for Structured and Object Oriented Design - DO UNTIL Structures

DO UNTIL Examples

Page 13: Tools for Structured and Object Oriented Design - DO UNTIL Structures

DOWHILE vs. DOUNTIL

Page 14: Tools for Structured and Object Oriented Design - DO UNTIL Structures

DOWHILE vs. DOUNTIL