Using the Priming Read Priming read (or priming input):

Slides:



Advertisements
Similar presentations
Chapter 2: Understanding Structure
Advertisements

Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program.
Programming Logic and Design Eighth Edition
CHAPTER 5: Repetition Control Structure. Objectives  To develop algorithms that use DOWHILE and REPEAT.. UNTIL structures  Introduce a pseudocode for.
Understanding the Three Basic Structures
ALGORITHMS THIRD YEAR BANHA UNIVERSITY FACULTY OF COMPUTERS AND INFORMATIC Lecture two Dr. Hamdy M. Mousa.
Lesson 5 - Decision Structure By: Dan Lunney
An Object-Oriented Approach to Programming Logic and Design
Programming Logic and Design Seventh Edition
CS0004: Introduction to Programming Repetition – Do Loops.
Programming Logic and Design Seventh Edition
Repeating Actions While and For Loops
Chapter 2: Algorithm Discovery and Design
Chapter 2: Algorithm Discovery and Design
Switch structure Switch structure selects one from several alternatives depending on the value of the controlling expression. The controlling expression.
Chapter 5: Control Structures II (Repetition)
Understanding the Mainline Logical Flow Through a Program (continued)
1 Fall 2007ACS-1903 Ch 4 Loops and Files Increment & decrement statements while loop do-while loop Other topics later on …
Chapter 2: Algorithm Discovery and Design
Chapter 2: Algorithm Discovery and Design
ECE122 L9: While loops March 1, 2007 ECE 122 Engineering Problem Solving with Java Lecture 9 While Loops.
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
Programming Logic and Design Fourth Edition, Introductory
Programming Logic and Design Sixth Edition
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science, C++ Version, Third Edition.
Invitation to Computer Science, Java Version, Second Edition.
Chapter 3 Making Decisions
Programming Logic and Design Fifth Edition, Comprehensive
Programming Logic and Design Fourth Edition, Comprehensive Chapter 6 Looping.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 4 Looping.
CHAPTER 2: Understanding Structure. Objectives 2  Learn about the features of unstructured spaghetti code  Understand the three basic structures: sequence,
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Programming Logic and Design, Introductory, Fourth Edition1 Understanding the Three Basic Structures Structure: a basic unit of programming logic Any program.
2 Chapter 21 Understanding Structure Programming Logic and Design, Second Edition, Comprehensive 2.
An Object-Oriented Approach to Programming Logic and Design Chapter 5 Making Decisions.
Programming Logic and Design Fifth Edition, Comprehensive
Chapter 7: The Repetition Structure Introduction to Programming with C++ Fourth Edition.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 5 Making Decisions.
An Object-Oriented Approach to Programming Logic and Design Second Edition Chapter 2 Understanding Structure.
P ROGRAMMING L OGIC GWDA123 Sharon Kaitner, M.Ed. Winter 2015: Week 2.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science.
Programming Logic and Design Fourth Edition, Introductory Chapter 2 Understanding Structure.
An Introduction to Programming with C++ Sixth Edition Chapter 8 More on the Repetition Structure.
Programming Logic and Design Seventh Edition
Chapter 8: More on the Repetition Structure
Chapter 5: Control Structures II (Repetition)
The switch Statement, and Introduction to Looping
Programming Logic and Design Fourth Edition, Comprehensive
Programming Logic and Design Eighth Edition
Control Structures II (Repetition)
Chapter 5: Repetition Structures
A Beginner’s Guide to Programming Logic, Introductory
Understanding the Reasons for Structure
Loop Control Structure.
Introduction to pseudocode
Chapter 6: Repetition Structures
Chapter 5: Repetition Structures
Understanding the Three Basic Structures
Patterns to KNOW.
Iteration Implemented through loop constructs (e.g., in C++)
Chapter 8: More on the Repetition Structure
Three Special Structures – Case, Do While, and Do Until
Writing a Complete Program
Boolean Expressions to Make Comparisons
Class 4: Repetition Pretest Posttest Counting Flowchart these!
Selection Structures: Single-alternative
Chapter 4: Writing and Designing a Complete Program
Presentation transcript:

Using the Priming Read Priming read (or priming input): Reads the first input data record Outside the loop that reads the rest of the records Helps keep the program structured Analyze a flowchart for structure one step at a time Watch for unstructured loops that do not follow this order: First ask a question Take action based on the answer Return to ask the question again Programming Logic and Design, Introductory, Fourth Edition

Using the Priming Read (continued) Unstructured loop: Programming Logic and Design, Introductory, Fourth Edition

Using the Priming Read (continued) Structured but nonfunctional loop Programming Logic and Design, Introductory, Fourth Edition

Using the Priming Read (continued) Corrrect Programming Logic and Design, Introductory, Fourth Edition

Using the Priming Read (continued) Functional and structured loop Programming Logic and Design, Introductory, Fourth Edition

Using the Priming Read (continued) Priming read sets up the process so the loop can be structured To analyze a flowchart’s structure, try writing pseudocode for it Programming Logic and Design, Introductory, Fourth Edition

Using the Priming Read (continued) What is wrong with this design? Programming Logic and Design, Introductory, Fourth Edition

Understanding the Reasons for Structure Advantages of structure: Provides clarity Professionalism Efficiency Ease of maintenance Supports modularity Programming Logic and Design, Introductory, Fourth Edition

Understanding the Reasons for Structure (continued) Programming Logic and Design, Introductory, Fourth Edition

Recognizing Structure (continued) Next, pull up the flowline on the right side of B Programming Logic and Design, Introductory, Fourth Edition

Recognizing Structure (continued) Now pull up the flowline on the right side of D Programming Logic and Design, Introductory, Fourth Edition

Recognizing Structure (continued) Bring together the loose ends of D and of B Programming Logic and Design, Introductory, Fourth Edition

Three Special Structures – Case, Do While, and Do Until Many languages allow three additional structures: case structure do-while structure do-until structure Case Structure: Decisions with more than two alternatives Tests a variable against a series of values and takes action based on a match Nested if-then-else statements will do what a case structure does Programming Logic and Design, Introductory, Fourth Edition

Three Special Structures – Case, Do While, and Do Until (continued) Using nested if-then-else for multiple alternatives Programming Logic and Design, Introductory, Fourth Edition

Three Special Structures – Case, Do While, and Do Until (continued) Using a case structure for multiple alternatives Programming Logic and Design, Introductory, Fourth Edition

Three Special Structures – Case, Do While, and Do Until (continued) do-while and do-until loops Question is asked at the end of the loop structure Ensures that the loop statements are always used at least once Programming Logic and Design, Introductory, Fourth Edition

Three Special Structures – Case, Do While, and Do Until (continued) do-while loop executes as long as the question’s answer is Yes or True Test checked at beginning May not be executed do-until loop executes as long as the question’s answer is No or False (until it becomes Yes or True) Test checked at end of loop Will always execute loop at least once Programming Logic and Design, Introductory, Fourth Edition

Three Special Structures – Case, Do While, and Do Until (continued) while loop with question at beginning is called a pretest loop do-until with question at end are called posttest loops Programming Logic and Design, Introductory, Fourth Edition

Three Special Structures – Case, Do While, and Do Until (continued) Programming Logic and Design, Introductory, Fourth Edition

Three Special Structures – Case, Do While, and Do Until (continued) Programming Logic and Design, Introductory, Fourth Edition