Figure 9.9Duplicate Data Names 01 STUDENT-RECORD. 05 STUDENT-NAMEPIC X(20). 05 SOCIAL-SECURITY-NUMPIC 9(9). 05 STUDENT-ADDRESS. 10 STREETPIC X(15). 10.

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Advertisements

Chapter 13 Control Structures. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Control Structures Conditional.
Figure 3.4The Building Blocks of Structured Programming A B (a) Sequence BA CONDITION? (b) Selection : ENTRYEXIT A B N (d) Case CONDITION? A (c) Iteration.
Selection (decision) control structure Learning objective
Conditions.. IF Syntax.   Simple Conditions l Relation Conditions l Class Conditions l Sign Conditions   Complex Conditions   Condition Names 
BY: JOSHUA THOMAS IGNATIUS TOWERS COBOL. Overview What is COBOL History Design Implementations What did it do Program structure Data types Syntax Sample.
1 Lecture 8:Control Structures I (Selection) (cont.) Introduction to Computer Science Spring 2006.
1 Objectives You should be able to describe: Relational Expressions The if-else Statement Nested if Statements The switch Statement Common Programming.
Chapter 2: Algorithm Discovery and Design
Chapter 8 . Sequence Control
C++ for Engineers and Scientists Third 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)
COBOL Programming DAY 2. Copyright © 2005, Infosys Technologies Ltd 2 ER/CORP/CRS/LA01/003 Version 1.0  Data Movement verbs.  Sequence Control verbs.
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)
1 Chapter 4. To familiarize you with methods used to 1. Access input and output files 2. Read data from an input file 3. Perform simple move operations.
History COBOL (Common Business Oriented Language) was one of the earliest high-level programming languages. COBOL was first proposed in 1959 by the Conference.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science, C++ Version, Third Edition.
Lecture Set 5 Control Structures Part D - Repetition with Loops.
COBOL Cobol is one of the most robust language in the software field, so far Cobol turned 50, in 2009 Cobol has stood the test of time Common Business.
Programming in COBOL-85 For IBM Mainframe System 390 Jyothi Sridhar Kini E&R, Infosys Mail-id: Phone:
Designing and Debugging Batch and Interactive COBOL Programs Chapter 5.
Programming Fundamentals. Today’s lecture Decisions If else …… Switch Conditional Operators Logical Operators.
1 Chapter 4: Selection Structures. In this chapter, you will learn about: – Selection criteria – The if-else statement – Nested if statements – The switch.
Selection Control Structures Simple Program Design Third Edition A Step-by-Step Approach 4.
2 Objectives You should be able to describe: Relational Expressions Relational Expressions The if-else Statement The if-else Statement Nested if Statements.
Selection Control Structures. Simple Program Design, Fourth Edition Chapter 4 2 Objectives In this chapter you will be able to: Elaborate on the uses.
Lesson NUMERIC-FIELDPIC 9(5). 05 ALPHANUMERIC-FIELDPIC X(5).... IF NUMERIC-FIELD = 10...(valid entry) IF NUMERIC-FIELD = ‘10’... (invalid entry)
1 Chapter – 12 Table Lookups Table Codes –Expanded Values –Types of Codes Numeric Alphabetic Alphanumeric.
Mr. Dave Clausen1 La Cañada High School Chapter 6: Repetition Statements.
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.
Controlling Execution Programming Right from the Start with Visual Basic.NET 1/e 8.
Statement Syntax1 THE SELECT STATEMENT Purpose: designates a file and points to its physical location Syntax Definition : SELECT file-name-1 ASSIGN TO.
Pseudocode Simple Program Design Third Edition A Step-by-Step Approach 2.
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.
U More sophisticated decisions may require a multiplicity of options. u These can be handled by combining a series of if…else constructs into what is called.
CMP-MX21: Lecture 4 Selections Steve Hordley. Overview 1. The if-else selection in JAVA 2. More useful JAVA operators 4. Other selection constructs in.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Python Mini-Course University of Oklahoma Department of Psychology Day 2 – Lesson 7 Conditionals and Loops 4/18/09 Python Mini-Course: Day 2 - Lesson 7.
5-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
CSC115 Introduction to Computer Programming Zhen Jiang Dept. of Computer Science West Chester University West Chester, PA 19383
11- 1 Chapter 11.  Avoiding Logic Errors by Validating Input  What to Do If Input Errors Occur  Global Considerations in COBOL  When Data Should Be.
Chapter 8 Decision Making Using the IF and EVALUATE Statements.
1 Chapter 5 – The Procedure Division File handling statements –OPEN statement Initiates processing for a file Input Output Each file opened must have been.
Chapter 8 – Data Validation
1 Chapter 13 - Mutlilevel Tables System Concepts –User View of tables one dimension view two dimension view three dimension view.
1 Chapter 9. To familiarize you with  Simple PERFORM  How PERFORM statements are used for iteration  Options available with PERFORM 2.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
One & Two dimensional Tables Cont.. Table of Major Codes 02ART HISTORY 04BIOLOGY 19CHEMESTRY 21CIVIL ENGINEERING 24COMP INF SYS 32ECONOMICS 39FINANCE.
CPS120 Introduction to Computer Science Iteration (Looping)
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Programming Logic and Design, Introductory, Fourth Edition1 Understanding the Three Basic Structures Structure: a basic unit of programming logic Any program.
 Control Flow statements ◦ Selection statements ◦ Iteration statements ◦ Jump statements.
This is It! It’s been a pleasure! Final Exam – format True / false 5 Multiple choice 5 Short answers10 Data manipulation10 SQL 3 Array’s12 File processing25.
11- 1 Chapter 11.  Avoiding Logic Errors by Validating Input  What to Do If Input Errors Occur  Global Considerations in COBOL  When Data Should Be.
A First Book of C++ Chapter 4 Selection. Objectives In this chapter, you will learn about: –Relational Expressions –The if-else Statement –Nested if Statements.
Chapter 4 PROCEDURE DIVISION. Paragraphs PROCEDURE DIVISION divided into paragraphs Each is independent module or routine Made up of series of instructions.
The PERFORM. The PERFORM Verb  Iteration is an important programming construct. We use iteration when we need to repeat the same instructions over and.
Programming Logic and Design Fifth Edition, Comprehensive
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.
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.
A First Book of C++ Chapter 4 Selection.
Sequence, Selection, Iteration The IF Statement
Control Structures.
Professor Jodi Neely-Ritz CGS3460
Iteration: Beyond the Basic PERFORM
Iteration: Beyond the Basic PERFORM
statement. Another decision statement, , creates branches for multi-
Presentation transcript:

Figure 9.9Duplicate Data Names 01 STUDENT-RECORD. 05 STUDENT-NAMEPIC X(20). 05 SOCIAL-SECURITY-NUMPIC 9(9). 05 STUDENT-ADDRESS. 10 STREETPIC X(15). 10 CITY-STATEPIC X(15). 05 ZIP-CODEPIC X(5). 05 CREDITSPIC 9(3). 05 MAJORPIC X(10). 05 FILLERPIC X(3) PRINT-LINE. 05 STUDENT-NAMEPIC X(20). 05 FILLERPIC XX. 05 CREDITSPIC 9(3). 05 FILLERPIC XX. 05 TUITIONPIC $$,$$ FILLERPIC XX. 05 STUDENT-ADDRESS. 10 STREETPIC X(15). 10 CITY-STATEPIC X(15). 10 ZIP-CODEPIC X(5). 05 FILLERPIC XX. 05 SOCIAL-SECURITY-NUMPIC 999B99B FILLERPIC X(47). (a) Duplicate Data Names

Figure 9.9Duplicate Data Names MOVE CORRESPONDING STUDENT-RECORD TO PRINT-LINE (b) MOVE CORRESPONDING Statement MOVE STUDENT-NAME OF STUDENT-RECORD TO STUDENT-NAME OF PRINT-LINE. MOVE SOCIAL-SECURITY-NUM OF STUDENT-RECORD TO SOCIAL-SECURITY-NUM OF PRINT-LINE. MOVE STREET OF STUDENT-RECORD TO STREET OF PRINT-LINE. MOVE CITY-STATE OF STUDENT-RECORD TO CITY-STATE OF PRINT-LINE. MOVE CREDITS OF STUDENT-RECORD TO CREDITS OF PRINT-LINE. (c) Equivalent MOVE Statements

CONDITION? A A TRUE FALSE (a) DO WHILE Construct(b) DO UNTIL Construct The Iteration Structure

The PERFORM Verb Structured Programming uses iteration as an integral part of its main constructs. In COBOL the PERFORM statement handles all the different iterations. We will discuss the different variations of the Perform. But first, how do we define a paragraph

Paragraph Scope The scope of ‘100-INITIALIZATION-RTN’ is delimited by the occurrence of the paragraph name ‘200-PROCESS-SCREEN-RECORD-RTN’. Paragraph Scope The scope of ‘100-INITIALIZATION-RTN’ is delimited by the occurrence of the paragraph name ‘200-PROCESS-SCREEN-RECORD-RTN’.

PERFORM statement formats Basic PERFORM PERFORM... TIMES phrase. PERFORM... UNTIL phrase. PERFORM...VARYING phrase..

PERFORM variation examples PERFORM 1000-INITIALIZATION-RTN (THRU 100-EXIT). PERFORM 420-PRINT-RTN 2 TIMES. PERFORM 2000-PROCESS-SCREEN-RECORD-RTN UNTIL WS-FUNCTION-KEY-03. PERFORM 300-PRINT-RTN VARYING SUB FROM 1 BY 1 UNTIL SUB > 12 PERFORM UNTIL END-OF-FILE-SWITCH = 'YES’... END-PERFORM.

The Basic Peform This is the only type of PERFORM that is not an iteration construct. It instructs the computer to transfer control to an out-of-line block of code. When the end of the block is reached, control reverts to the statement (not the sentence) immediately following the PERFORM. 1stProc and EndProc are the names of Paragraphs or Sections. The PERFORM..THRU instructs the computer to treat the Paragraphs or Sections from 1stProc TO EndProc as a single block of code.

Keep them in line when possible The out-of-line Perform The in-line Perform Avoid GO TOs

READ INPUT-FILE AT END MOVE ‘NO’ TO DATA-REMAINS-SWITCH. PERFORM PROCESS-RECORDS UNTIL DATA-REMAINS-SWITCH = ‘NO’. PROCESS-RECORDS.... READ INPUT-FILE AT END MOVE ‘NO’ TO DATA-REMAINS-SWITCH. (a) Priming Read PERFORM UNTIL DATA-REMAINS-SWITCH = ‘NO’ READ INPUT-FILE AT END MOVE ‘NO’ TO DATA-REMAINS-SWITCH NOT AT END... END-READ END-PERFORM. (b) False Condition Branch with In-Line Perform Procedure Division statements to process the current record Figure 9.2Structure of a COBOL Program

EVALUATE Statement In many cases nested IF statements can be replaced by an EVALUATE statement. The EVALUATE statement evaluates multiple conditions and a particular action is taken depending on the results of these evaluations. Implements the Case Structure

IF Syntax. Simple Conditions –Relation Conditions –Class Conditions –Sign Conditions Complex Conditions Condition Names Simple Conditions –Relation Conditions –Class Conditions –Sign Conditions Complex Conditions Condition Names C ONDITION T YPES

The Evaluate statement EVALUATE TRUE WHEN STU-CREDITS <= 1ST-CREDIT-LIMIT MOVE 1ST-ACTIVITY-FEE TO IND-ACTIVITY-FEE WHEN STU-CREDITS > 1ST-CREDIT-LIMIT AND STU-CREDITS <= 2ND-CREDIT-LIMIT MOVE 2ND-ACTIVITY-FEE TO IND-ACTIVITY-FEE WHEN STU-CREDITS > 2ND-CREDIT-LIMIT MOVE 3RD-ACTIVITY-FEE TO IND-ACTIVITY-FEE WHEN OTHER DISPLAY 'INVALID CREDITS FOR: ' STU-NAME END-EVALUATE.

Check pgm Tuition5

EVALUATE MENU-INPUT WHEN "0" PERFORM INIT-PROC WHEN "1" THRU "9" PERFORM PROCESS-PROC WHEN "R" PERFORM READ-PARMS WHEN "X" PERFORM CLEANUP-PROC WHEN OTHER PERFORM ERROR-PROC END-EVALUATE. Equivalent Nested If’s IF (MENU-INPUT = "0") THEN PERFORM INIT-PROC ELSE IF (MENU-INPUT ° "1") AND (MENU-INPUT ° "9") THEN PERFORM PROCESS-PROC ELSE IF (MENU-INPUT = "R") THEN PERFORM READ-PARMS ELSE IF (MENU-INPUT = "X") THEN PERFORM CLEANUP-PROC ELSE PERFORM ERROR-PROC END-IF END-IF.

Why all these varieties? Did you hear about the Law of the Hammer If the only tool you have is a hammer you will always try pounding as the best and only solution