loop_chpt9 - Introduction to Computing LOOPING Chapter 6 To...

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

View Full Document Right Arrow Icon
Introduction to Computing LOOPING Chapter 6
Background image of page 1

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

View Full DocumentRight Arrow Icon
To design a loop, you must know the following: 1. What is the condition that ends a loop 2. How should the condition be initialized 3. How should the condition be updated 4. What is the process being repeated 5. How should the process be initialized 6. How should the process be updated 7. What is the state of the program on exiting the loop
Background image of page 2
Count-control loops A loop starts with some number initialized and continues as long as that counter‟s final values has not been reached. This can be progressive or regressive. For a count-control loop to function properly, a counter must be initiated and updated each time the loop is actuated. The counter is usually incremented or decremented by some value such as one.
Background image of page 3

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

View Full DocumentRight Arrow Icon
EOF-control loops A loop starts when a file is opened and continues until all of the data has been used (read) and the pointer reaches an EOF marker. This is normally an easy operation in java especially with the swing components. The file must be opened and verified. The standard method for reading a file is to read each data element. Remember, you MUST know what the data elements are in a file and their configuration. If there is no data, the EOF marker will never be reached.
Background image of page 4
Sentinel-control loops This process involves a priming read condition or variable either from the keyboard, a file, or the program. The sentinel control loop must answer several questions. For a file, open it and read
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/27/2011 for the course CSC 111 taught by Professor Dr.preston during the Fall '11 term at Oral Roberts.

Page1 / 28

loop_chpt9 - Introduction to Computing LOOPING Chapter 6 To...

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

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