Slieds - Chapter 5

Slieds - Chapter 5 - Chapter5 ListsandLoops 1 BMGT302...

Info iconThis preview shows pages 1–17. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 5 Lists and Loops BMGT 302 Business Application  Programming 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The Repetition Structure  Repetition structure  (or  loop ): a structure that  repeatedly processes one or more program instructions  until a condition is met Looping condition : the requirement for repeating  the instructions Loop exit condition : the requirement for not  repeating the instructions 2
Background image of page 2
The Repetition Structure (cont’d.) Example of a looping condition and a loop exit condition 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The Repetition Structure (cont’d.) Problem specification for the Getting to a Million Club application Sample run of the Getting to a Million Club application 4
Background image of page 4
The Repetition Structure (cont’d.) Pseudocode containing only the sequence structure 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The Repetition Structure (cont’d.) 6 What if we change the application requirement to 
Background image of page 6
Modified problem specification and pseudocode containing a loop 7
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The Repetition Structure (cont’d.)  Pretest loop   The condition is evaluated before the instructions within  the loop are processed The instructions may be processed zero or more times Posttest loop   The condition is evaluated after the instructions within the  loop are processed The instructions are always processed at least once 8
Background image of page 8
The Repetition Structure (cont'd.) Repetition statements in Visual Basic Do. ..Loop For. ..Next For Each. ..Next 9
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The Do. ..Loop Statement Do. ..Loop statement : codes both a pretest and  posttest loop Loop body : the instructions between the Do and the  Loop clauses Use  While  or  Until   to code the condition for the loop Repetition symbol in a flowchart is the diamond 10
Background image of page 10
How to use the Do…Loop statement 11
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The Do. ..Loop Statement (cont'd.)  Flowchart for the pretest loop example from Figure 6-6 12
Background image of page 12
The Do. ..Loop Statement (cont'd.) Flowchart for the posttest loop example from Figure 6-6 13
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Using Counters and Accumulators Counter : a numeric variable used for counting Accumulator : a numeric variable used for  accumulating (adding together) Initializing : assigning a beginning value to a  counter or accumulator variable Updating  (or  incrementing ): adding a number  to the value of a counter or accumulator variable Counters are always incremented by a constant  value, usually 1 14
Background image of page 14
Modified pseudocode and code for the calcButton’s Click event  procedure 15
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Demo 5-1: running the Getting into a Million  Club application. 16
Background image of page 16
Image of page 17
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/21/2011 for the course BMGT 302 taught by Professor Huang during the Fall '11 term at Maryland.

Page1 / 95

Slieds - Chapter 5 - Chapter5 ListsandLoops 1 BMGT302...

This preview shows document pages 1 - 17. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online