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)

Slides:



Advertisements
Similar presentations
You have been given a mission and a code. Use the code to complete the mission and you will save the world from obliteration…
Advertisements

Chapter 4 Loops Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved
4 Control Statements: Part 1.
Chapter 5: Control Structures II (Repetition)
Advanced Piloting Cruise Plot.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Chapter 1 The Study of Body Function Image PowerPoint
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 5 Author: Julia Richards and R. Scott Hawley.
1 Copyright © 2013 Elsevier Inc. All rights reserved. Appendix 01.
1 Copyright © 2010, Elsevier Inc. All rights Reserved Fig 2.1 Chapter 2.
By D. Fisher Geometric Transformations. Reflection, Rotation, or Translation 1.
Chapter 1 Image Slides Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
© 2010 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 5: Repetition and Loop Statements Problem Solving & Program.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Title Subtitle.
0 - 0.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
ADDING INTEGERS 1. POS. + POS. = POS. 2. NEG. + NEG. = NEG. 3. POS. + NEG. OR NEG. + POS. SUBTRACT TAKE SIGN OF BIGGER ABSOLUTE VALUE.
SUBTRACTING INTEGERS 1. CHANGE THE SUBTRACTION SIGN TO ADDITION
MULT. INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
Addition Facts
Year 6 mental test 5 second questions
Year 6 mental test 10 second questions
ZMQS ZMQS
Multiplication Tile Facts Multiplication Tile Facts Rectangular next © 2009 Richard A. Medeiros.
ABC Technology Project
VOORBLAD.
Progam.-(6)* Write a program to Display series of Leaner, Even and odd using by LOOP command and Direct Offset address. Design by : sir Masood.
Factor P 16 8(8-5ab) 4(d² + 4) 3rs(2r – s) 15cd(1 + 2cd) 8(4a² + 3b²)
Squares and Square Root WALK. Solve each problem REVIEW:
Lets play bingo!!. Calculate: MEAN Calculate: MEDIAN
Sets Sets © 2005 Richard A. Medeiros next Patterns.
1 Chapter 4 The while loop and boolean operators Samuel Marateck ©2010.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 4 Loops.
CS101: Introduction to Computer programming
Chapter 5 Test Review Sections 5-1 through 5-4.
GG Consulting, LLC I-SUITE. Source: TEA SHARS Frequently asked questions 2.
Chapter 5 Loops Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved.
Addition 1’s to 20.
CS 240 Computer Programming 1
25 seconds left…...
Slippery Slope
Week 1.
We will resume in: 25 Minutes.
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
Essential Cell Biology
2-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)
Intracellular Compartments and Transport
1 Unit 1 Kinematics Chapter 1 Day
PSSA Preparation.
Essential Cell Biology
How Cells Obtain Energy from Food
Chapter 30 Induction and Inductance In this chapter we will study the following topics: -Faraday’s law of induction -Lenz’s rule -Electric field induced.
L6:CSC © Dr. Basheer M. Nasef Lecture #6 By Dr. Basheer M. Nasef.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 3 Loops.
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.
10-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)
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)
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.
5-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
1 Chapter 9. To familiarize you with  Simple PERFORM  How PERFORM statements are used for iteration  Options available with PERFORM 2.
Iteration: Beyond the Basic PERFORM
Iteration: Beyond the Basic PERFORM
Presentation transcript:

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) John Wiley & Sons, Inc. 11th edition

9-2 Iteration: Beyond the Basic PERFORM Chapter 9

9-3 In-Line PERFORM PERFORM. END-PERFORM Use when only a few statements are to be executed Modularize with PERFORM paragraph- name when many statements required Statements to be executed Format

9-4 Nested PERFORM PERFORM may be one of instructions in range of another PERFORM Perform 200-Paragraph. 200-Paragraph. Perform 500-Paragraph Nested PERFORM

9-5 Nested In-Line PERFORM In-line PERFORMs can include nested in-line PERFORMs or PERFORMs with paragraph-name Perform... Perform... End-Perform... End-Perform

9-6 PERFORM UNTIL PERFORM [paragraph-name-1] UNTIL condition-1 Repeats statements in paragraph until condition is true Called iteration or loop Format

9-7 Loop Example Write Hello-Record-Out 3 times Move Zeros To Count Perform Until Count = 3 Write Hello-Record-Out Add 1 To Count End-Perform

9-8 PERFORM … TIMES Executes a sequence of steps a fixed number of times No counter needed Loop below executes paragraph 300- Print-Rtn 5 times Perform 300-Print-Rtn 5 Times

9-9 Loop Example Sum even integers from 2 through 10 Initialize a field to first number to be added (2) Increment field by 2 so it equals even numbers (2, 4, 6, 8, 10) Use this field's value to –Test in condition –Add to a total field to find sum

9-10 Code for Loop Example Sum even integers from 2 through 10 Move 0 To Total Move 2 To Count Perform Until Count > 10 Add Count To Total Add 2 To Count End-Perform Display 'Total=', Total Initialize field to be tested Test field until it reaches desired value Change field tested so condition eventually met Result: Total = 30

9-11 Nested PERFORMs One of statements in PERFORM loop may be another PERFORM loop A loop within another loop is called a nested loop

9-12 Nested PERFORM Pseudocode Perform 5 Times Perform 10 Times Read record from file and add its amount to group total End-Read End-Perform Perform Print-Group-Total End-Perform Outer loop Inner loop

9-13 TIMES vs UNTIL Use PERFORM … TIMES if you know in advance the number of times loop statements are to be executed Use PERFORM … UNTIL if number of times loop repeated is needed for output or calculations

9-14 PERFORM VARYING PERFORM VARYING identifier-1 identifier-2identifier-3 FROM BY integer-1integer-2 UNTIL condition-1 statement-1 … END-PERFORM Format

9-15 PERFORM VARYING Repeatedly executes statements in loop while varying value of a field First identifier-1 is given FROM value Condition then tested Executes statements in loop if condition not met Then adds BY value to identifier-1 and repeats condition test

9-16 PERFORM VARYING Example Perform Varying Ctr From 1 By 1 Until Ctr > 5 Display 'Ctr = ', Ctr End-Perform Sets Ctr to 1, since Ctr > 5 not true, executes DISPLAY statement Increments Ctr by 1, tests condition again

9-17 PERFORM VARYING Execution CTRCondition Output 11 > 5 falseCtr = 1 22 > 5 falseCtr = 2 33 > 5 falseCtr = 3 44 > 5 falseCtr = 4 55 > 5 falseCtr = 5 66 > 5 true(loop ends)

9-18 PERFORM VARYING Examples Finds sum of odd numbers from 1 to 25 Move 0 To Total Perform Varying Ctr From 1 By 2 Until Ctr > 25 Add Ctr To Total End-Perform Display 'Total = ', Total Output: Total = 169

9-19 PERFORM VARYING Examples Statements to be repeated may also be in separate paragraph Perform 300-Process-Rtn Varying Ctr From 1 By 1 Until Ctr > 20 Executes 300-Process-Rtn 20 Times

9-20 Nested PERFORM VARYING May include a PERFORM VARYING loop as one of statements in another PERFORM VARYING loop Each time outer loop is repeated, inner loop is executed until its condition is met Following example prints the times tables for numbers 1 to 9

9-21 Print Times Tables Perform Varying N1 From 1 By 1 Until N1 > 9 Perform Varying N2 From 1 By 1 Until N2 > 9 Compute Product = N1 * N2 Display N, ' * ' M ' = ', Product End-Perform Outer loop Inner loop

9-22 Print Times Tables Execution N1N2 Output 111 * 1 = * 2 = * 9 = * 1 = * 2 = * 9 = 18 Outer loop first time Inner loop repeats 9 times Outer loop second time Inner loop repeats 9 times

9-23 Print Times Tables Execution Outer loop repeated seven more times Each time, statements in inner loop are repeated 9 times –N2 initialized to 1 and incremented by 1 each time through inner loop until N2 > 9 Outer loop ends after printing 9's table

9-24 TEST AFTER Example Perform With Test After Until Opt-Num >=1 And <= 5 Display 'Select option (1-5)' Accept Opt-Num End-Perform Example

9-25 TEST AFTER Example Condition is not checked before loop begins DISPLAY and ACCEPT for user to enter Opt-Num always executed at least once Checks Opt-Num after user types in value for first time If Opt-Num not a value from 1 to 5, loop is repeated

9-26 Copyright © 2003 John Wiley & Sons, Inc. All rights reserved. Reproduction or translation of this work beyond that permitted in Section 117 of the 1976 United States Copyright Act without the express written permission of the copyright owner is unlawful. Request for further information should be addressed to the Permissions Department, John Wiley & Sons, Inc. The purchaser may make back-up copies for his/her own use only and not for distribution or resale. The Publisher assumes no responsibility for errors, omissions, or damages, caused by the use of these programs or from the use of the information contained herein. The original presentation has been modified.