5-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.

Slides:



Advertisements
Similar presentations
9-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Advertisements

8-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Chapter 2 - Problem Solving
7-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
5-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
ITEC113 Algorithms and Programming Techniques
Chapter 8 and 9 Review: Logical Functions and Control Structures Introduction to MATLAB 7 Engineering 161.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 3 - Structured Program Development Outline.
Program Design and Development
Pseudocode and Algorithms
Program Development and Programming Languages
COBOL for the 21 st Century Stern, Stern, Ley Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.
Chapter 1 Program Design
Structured Program Development in C
Problem Solving Chapter 2. What is an algorithm? n A solution to a problem that is: –Precise –Effective –Terminating.
Chapter 3 Planning Your Solution
PRE-PROGRAMMING PHASE
COBOL for the 21st Century
Structured COBOL Programming
Fundamentals of Python: From First Programs Through Data Structures
Fundamentals of Python: First Programs
Structured COBOL Programming, Stern & Stern, 9th Edition PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured.
Structured COBOL Programming, Stern & Stern, 9th edition
4-1 Coding Complete COBOL Programs: The PROCEDURE DIVISION Chapter 4.
4-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
12-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
4-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Structured COBOL Programming
1-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
Designing and Debugging Batch and Interactive COBOL Programs Chapter 5.
7-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
Structured Program Development Outline 2.1Introduction 2.2Algorithms 2.3Pseudo code 2.4Control Structures 2.5The If Selection Structure 2.6The If/Else.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
BACS 287 Programming Logic 1. BACS 287 Programming Basics There are 3 general approaches to writing programs – Unstructured – Structured – Object-oriented.
1 The Procedure Division Chapter 4. 2 Main Two Sections File Section –Used to define files and record formats –Field names within records Working Storage.
C Lecture Notes 1 Structured Program Development.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
9-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
9-1 Iteration: Beyond the Basic PERFORM Chapter 9.
Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout.
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
7-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
`. Lecture Overview Structure Programming Basic Control of Structure Programming Selection Logical Operations Iteration Flowchart.
1 Chapter 9. To familiarize you with  Simple PERFORM  How PERFORM statements are used for iteration  Options available with PERFORM 2.
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
P ROGRAMMING L OGIC GWDA123 Sharon Kaitner, M.Ed. Winter 2015: Week 2.
Pseudocode. Algorithm A procedure for solving a problem in terms of the actions to be executed and the order in which those actions are to be executed.
 Problem Analysis  Coding  Debugging  Testing.
Programming Logic and Design Fourth Edition, Introductory Chapter 2 Understanding Structure.
Chapter 3: Decisions and Loops
ALGORITHMS AND FLOWCHARTS
Introduction To Flowcharting
Programming Fundamentals
Designing and Debugging Batch and Interactive COBOL Programs
Problem Solving Techniques
Structured Program
Structured COBOL Programming
Iteration: Beyond the Basic PERFORM
Iteration: Beyond the Basic PERFORM
Chapter 2- Visual Basic Schneider
Chapter 2- Visual Basic Schneider
ICT Gaming Lesson 2.
Presentation transcript:

5-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John Wiley & Sons, Inc. PowerPoint Winifred J. Rex Presentation Bowling Green State University 10th edition

5-2 Chapter Objectives To familiarize you with 1.  Structured programs 2.  Pseudocode 3.  Hierarchy or Structure Charts 4.  Logical Control Structures 5.Good programming techniques 6.Interactive processing

5-3 Well-Designed Programs Are structured programs – when using procedural languages (COBOL, C, …) Use instructions executed in standardized order Divide program into modules, each performing a specific function Control returns to place module called from Simple PERFORM used in COBOL to execute modules (paragraphs)

5-4 Well-Designed Programs Use top-down approach Code modules in hierarchical order Main modules first, then secondary modules with detailed code Step-wise refinement Top modules are ‘control’ modules; abstract; drivers; contain ‘Performs’… As we go down the hierarchy, control becomes less and computations and data manipulation becomes greater.

5-5 Well-Designed Programs Are modular Group related statements together into modules Execute each module or paragraph in COBOL with simple PERFORM For example, statements to calculate students’ tuition in one module, statements to calculate room and board in another module

5-6 Designing Before Coding Design program first –So program will work efficiently –So program works as integrated whole –Design techniques applicable to all languages  Code program only after design done –Use syntax rules of language –Syntax rules are language-specific

5-7 Pseudocode Primary tool for planning program logic We will use structure charts for our architectural design and pseudo- code for our lower-level detail (algorithmic) design. Specifies instructions and logical control structures used by program Use one or more lines of pseudo-code to describe each program step

5-8 Four Logical Control Structures Used by structured programs to specify order in which instructions are executed 1.Sequence 2.Selection 3.Iteration 4.Case Structure All programs may be written using some combination of these control structures!

5-9 Sequence Instructions executed in order they appear Three instructions below executed one after the other (pseudo-code shown) START Read Amt1, Amt2 Compute Total = Amt1 + Amt2 Write Total STOP Note: no syntax; no periods, just generic procedure. Imperative statements. Nothing conditional or repetitive.

5-10 Selection (true / false) Instructions executed depending on existence of a condition Called IF-THEN-ELSE logical control structure Condition: if amt > 40 … The condition is amt>40. This is evaluated. It is either TRUE or FALSE. Present value of amt either equals 40 or not! Subsequent actions take place based on the truth value of the condition!

5-11 Selection Structure Pseudocode IF condition THEN instructions to do if condition exists ELSE instructions to do if condition doesn’t exist END-IF Example (again, this is in pseudocode.) IF X is Less Than Y THEN Add X To Y ELSE Subtract X From Y END-IF

5-12 Iteration (Looping Constructs) To specify repeated execution of series of steps Use in-line or standard PERFORM … UNTIL for iteration in COBOL –There are additional forms – later. Both execute group of instructions repeatedly until a condition is met

5-13 Iteration Pseudocode In-line PERFORM UNTIL PERFORM UNTIL condition.. statements to be repeated. END-PERFORM.. Statements following PERFORM. MUST use a scope terminator! Needed to ‘bound’ the scope. Note: statements within Perform may never be executed. Remember the ‘pre-condition’ followed by ‘post-conditions.’

5-14 Iteration Pseudocode Standard PERFORM UNTIL PERFORM paragraph-1 UNTIL condition.. Statements following PERFORM. Paragraph-1. located elsewhere in program.. statements to be repeated.

5-15 Infinite Loops In-line and standard PERFORM UNTIL both repeat instructions until condition met If condition never met, loop never ends Causes error called an infinite loop

5-16 Infinite Loops Make sure loop ends by including instruction in loop that causes condition to be met For example, if condition is WS-MORE-DATA = ‘NO’ Make sure there is statement in loop that sets WS-MORE-DATA to ‘NO’ when there is no more data

5-17 move 0 to counter. perform until counter > 10 …. end-perform Will generate an infinite loop: move 0 to counter. perform until counter = 10 …. add 1 to counter end-perform Will terminate loop after 10 iterations: Two Examples

5-18 Case Structure To choose from one of several sets of instructions depending on a condition For example, assume –Different instructions should be executed when field Code-In has values of 1, 2 or 3 –Any other value of Code-In is considered an error

5-19 Case Structure Pseudocode EVALUTATE Code-In WHEN 1 PERFORM paragraph-1 WHEN 2 PERFORM paragraph-2 WHEN 3 PERFORM paragraph-3 WHEN OTHER PERFORM error-paragraph END-EVALUATE Note: scope terminator, indentation. Will cause branches only if value of Code-In is either a 1 or a 2 or a 3; otherwise, error-paragraph will be performed. Note also: ‘integer’ values!

5-20 Hierarchy Charts (Structure Charts) To illustrate top-down relationships among modules Graphic method to divide program into modules Modules shown as rectangular boxes Relationships among modules represented by connected lines Note: only DOWN not across. We are functionally decomposing higher- level modules into its parts.

5-21 Example of Hierarchy Chart 0000-main 1000-some-name some-name xxx 1600-xxx 2300-yyy 2600-yyy 2900-yyy DISCUSS PARAGRAPH NAMING CONVENTIONS Very Important!

5-22 Hierarchy Chart Letters A-H represent modules or paragraphs A is main module B and C are subordinate modules called from main paragraph with a PERFORM D and E represent modules called from paragraph B We will use our standards.

5-23 Pseudocode and Hierarchy Charts Pseudocode shows actual sequence of instructions – detailed algorithmic steps. –Do this secondly Hierarchy charts show relationships among modules – higher level, architectural design. Do this first. Both help programmers –Develop efficient programs –Debug and modify programs

5-24 Naming Paragraphs Name up to 30 characters - letters, digits, hyphen Choose meaningful name that describes type of instructions in module Use numeric prefixes to indicate relative location of module in program Examples 1000-Main-Module 2000-Process- Data