STRUCTURED CONTROL: BASIC CONTROL OPERATORS

Slides:



Advertisements
Similar presentations
Programming with Microsoft Visual Basic th Edition
Advertisements

Methodology for Program Development Tuition billing program –Specs –File descriptions –Report layout –Processing requirement $200/cr $25 union dues if.
Repetition There are three different ways that a set of instructions can be repeated, and each way is determined by where the decision to repeat is.
Repetition Control Structures
Repetition control structures
Repetition Control Structures School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 9, Friday 3/07/2003)
Understanding the Three Basic Structures
ALGORITHMS THIRD YEAR BANHA UNIVERSITY FACULTY OF COMPUTERS AND INFORMATIC Lecture two Dr. Hamdy M. Mousa.
Chapter 3 IFTHENELSE Control Structure © 2008 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. Marilyn Bohl/Maria Rynn Tools for Structured.
Lesson 5 - Decision Structure By: Dan Lunney
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Programming Logic and Design Seventh Edition
Chapter 9: The Traditional Approach to Design Chapter 10 Systems Analysis and Design in a Changing World, 3 rd Edition.
Programming Logic and Design Seventh Edition
Chapter 2- Visual Basic Schneider
BACS 287 Programming Logic 3. BACS 287 Iteration Constructs Iteration constructs are used when you want to execute a segment of code several times. In.
Program Design and Development
Chapter 5: Loops and Files.
An Object-Oriented Approach to Programming Logic and Design Chapter 6 Looping.
Chapter 7 Problem Solving with Loops
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
DCT 1123 Problem Solving & Algorithms
Pseudocode algorithms using sequence, selection and repetition
Intro to Programming Logic and Design CIS 115 Brought to you by: done by Angela Robinson for CSC 289.
Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step.
10 The traditional approach to design Hisham Alkhawar.
Logic Structure - focus on looping Please use speaker notes for additional information!
6 Chapter 61 Looping Programming Logic and Design, Second Edition, Comprehensive 6.
Any Questions? Control Breaks Agenda Control Breaks –Also known as Reports with sub-totals.
Saeed Ghanbartehrani Summer 2015 Lecture Notes #5: Programming Structures IE 212: Computational Methods for Industrial Engineering.
Lecture 2 Control Structure. Relational Operators -- From the previous lecture Relational Operator Meaning == is equal to < is less than > is greater.
The world of Constructs Control Structures. The three Structures Sequence Selection Loop Entry Exit.
Pseudocode Algorithms Using Sequence, Selection, and Repetition Simple Program Design Third Edition A Step-by-Step Approach 6.
Count and add list of numbers From user input and from file.
CHAPTER 2: Understanding Structure. Objectives 2  Learn about the features of unstructured spaghetti code  Understand the three basic structures: sequence,
DOWHILE: Trailer Record Logic
1 Chapter 16 Component-Level Design. 2 Component-Level Design  the closest design activity to coding  the approach: review the design description for.
Master File Update Processing. Objectives On completing this section you should be able to: w Distinguish between online processing and batch processing.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Looping.
Programming Logic and Design, Introductory, Fourth Edition1 Understanding the Three Basic Structures Structure: a basic unit of programming logic Any program.
Copyright © 2012 Pearson Education, Inc. Chapter 5: Loops.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
ARITHMETIC OPERATORS COMPARISON/RELATIO NAL OPERATORS LOGIC OPERATORS ()Parenthesis>Greater than &&And ^Exponentiation=>=
Chapter Looping 5. The Increment and Decrement Operators 5.1.
Programming Logic and Design Fifth Edition, Comprehensive
Chapter Looping 5. The Increment and Decrement Operators 5.1.
Array Applications. Objectives Design an algorithm to load values into a table. Design an algorithm that searches a table using a sequential search. Design.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Chapter 7 CASE Control Structure © 2008 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. Marilyn Bohl/Maria Rynn Tools for Structured.
Programming Logic and Design Fourth Edition, Introductory Chapter 2 Understanding Structure.
Processing multiple files
Topic 4: Looping Statements
REPETITION CONTROL STRUCTURE
Chapter 5: Control Structures II (Repetition)
Chapter 2- Visual Basic Schneider
Control Structures II (Repetition)
Computer Science Faculty
Topics discussed in this section:
ALGORITHMS AND FLOWCHARTS
PROGRAM DESIGN CONCEPTS AND TECHNIQUES
Pseudocode algorithms using sequence, selection and repetition
Structured Program Design
Topics discussed in this section:
Understanding the Three Basic Structures
ALGORITHMS AND FLOWCHARTS
Chapter 2- Visual Basic Schneider
Chapter 8: More on the Repetition Structure
PROGRAM DESIGN CONCEPTS AND TECHNIQUES
DATA STRUCTURES 5/3/2019© 2006 ITT Educational Services Inc.
Presentation transcript:

STRUCTURED CONTROL: BASIC CONTROL OPERATORS 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 1

Objectives Create a flowchart and pseudocode to describe a conditional program. Identify situations in which an IFTHENELSE control structure meets the design requirements. Identify situations in which a CASE control structure meets the design requirements. Identify situations in which a counter-controlled loop meets the design requirements. Identify situations in which a trailer-record loop meets the design requirements. Choose between a DOWHILE and a DOUNTIL control structure. 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 2

IFTHENELSE P? No Yes d c 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 3

Sequential IFTHENELSE P? No Yes c Q? No Yes d 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 4

Nested IFTHENELSE P? Yes No c Q? Yes No e d 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 5

CASE Code? A ProcA B ProcB C ProcC Other ProcOther 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 6

Op Code Problem (Flowchart) Start Read OP, N1, N2 OP? Result= N1+N2 Result= N1+N2 Result= N1+N2 Result= N1+N2 Result= 0 Write ‘Bad input’ Write Result, N1, N2, Op Stop 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 7

DOWHILE Loop e Q? 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 8

Counter-controlled Loop Count=x Count<x Count>0 No No Yes Yes DoStuff DoStuff Count= Count+1 Count= Count-1 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 9

Averaging Problem (Flowchart) 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 10

Header Record Logic 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 11

Averaging Problem with Header Record 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 12

Averaging Problem with No-Data Test 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 13

Reading a File - Counter DOWHILE Loop PSEUDOCODE Count = 0 DOWHILE Count < 3 Read a record Write a record Count = Count+1 ENDDO Count=0 Count = Count + 1 Count < 3? Yes Read a record Write a record No 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 14

Reading a File - Header DOWHILE Loop PSEUDOCODE Count = 0 DOWHILE Count >0 Read a record Write a record Count = Count-1 ENDDO Count=0 Count = Count - 1 Count >0 Yes Read a record Write a record No 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 15

Reading a File - Trailer DOWHILE Loop PSEUDOCODE Read a record DOWHILE Code Not 999 Write a record ENDDO Read a record Code NOT 999? Yes Write a record Read a record No 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 16

Reading a File – Auto EOF DOWHILE Loop PSEUDOCODE Read a record DOWHILE Not EOF Write a record ENDDO Read a record Not EOF? Yes Write a record Read a record No 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 17

DOUNTIL Loop Read File DoStuff Yes Done? No 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 18

Adding Six Numbers Using DOUNTIL (Flowchart) 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 19

Property -- Counter-Controlled (Flowchart) 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 20

Property - Header Record Logic (Structure Chart) 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 21

Property -- Header Record Logic -- Overall Control (Flowchart) 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 22

DOWHILE vs. DOUNTIL - No Initial Test 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 23

DOWHILE vs. DOUNTIL - Initial Test 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 24

Summary In this unit, you learned: How to design a program with conditional logic IFTHENELSE Nested IFTHENELSE Case statements How to design a program that includes loops Counter-controlled DOWHILE loop Trailer record DOWHILE loop DOUNTIL loop 11/29/2018© 2006 ITT Educational Services Inc. Structured Programming: Unit 2 Slide 25