Chapter 1 1-1. To familiarize you with  Why COBOL is a popular business-oriented language.  Programming practices and techniques  History of COBOL.

Slides:



Advertisements
Similar presentations
2-1 Chapter 2.  Coding Requirements of IDENTIFICATION DIVISION  Sections of ENVIRONMENT DIVISION  Assigning Files to Devices in ENVIRONMENT DIVISION.
Advertisements

CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
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)
COSC 120 Computer Programming
Chapter 9 Describing Process Specifications and Structured Decisions
Program Flow Charting How to tackle the beginning stage a program design.
Program Flow Charting How to tackle the beginning stage a program design.
Modules, Hierarchy Charts, and Documentation
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
COBOL for the 21 st Century Stern, Stern, Ley Chapter 1 INTRODUCTION TO STRUCTURED PROGRAM DESIGN IN COBOL.
Chapter 1 Program Design
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 3 Planning Your Solution
Programming Logic and Design Fourth Edition, Introductory
COBOL for the 21st Century
Structured COBOL Programming
CS102 Introduction to Computer Programming
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
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)
Topics Introduction Hardware and Software How Computers Store Data
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Developing a Program.
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.
Simple Program Design Third Edition A Step-by-Step Approach
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)
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
History COBOL (Common Business Oriented Language) was one of the earliest high-level programming languages. COBOL was first proposed in 1959 by the Conference.
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.
The DATA DIVISION Chapter 3. COBOL Data Organization Field - group of characters forming a meaningful unit or basic fact –Characters in a name or digits.
3-1 Chapter 3. To familiarize you with  Ways in which data is organized in COBOL  Rules for forming data-names  Defining input and output files in.
3-1 The DATA DIVISION Chapter Chapter Objectives To familiarize you with Systems design considerations Ways in which data is organized Rules for.
1 Interactive vs Batch Programs Cobol suited for developing both types of programs Interactive programs Accept input data from keyboard Input data processed.
CS CS Computing for Business Instructor:David Tucker GTA:Batul Mirza.
Chapter 7 File I/O 1. File, Record & Field 2 The file is just a chunk of disk space set aside for data and given a name. The computer has no idea what.
Indexed and Relative File Processing
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
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.
13-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)
CPSC3111/CISM3111 COBOL Structured COBOL Programming Text: murach’s structured COBOL Authors: Murach, Prince, Menendez.
Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout.
Structured Programming
1 Program Planning and Design Important stages before actual program is written.
Structured COBOL Programming, Stern & Stern, 9th Edition CHAPTER 2 Cobol Language Fundamentals.
13-1 Sequential File Processing Chapter Chapter Contents Overview of Sequential File Processing Sequential File Updating - Creating a New Master.
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
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)
Submitted To: Rutvi sarang Submitted By: Kushal Bhagat.
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
13- 1 Chapter 13.  Overview of Sequential File Processing  Sequential File Updating - Creating a New Master File  Validity Checking in Update Procedures.
The Hashemite University Computer Engineering Department
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 4 PROCEDURE DIVISION. Paragraphs PROCEDURE DIVISION divided into paragraphs Each is independent module or routine Made up of series of instructions.
Alexandria University Faculty of Science Computer Science Department Introduction to Programming C++
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
 Problem Analysis  Coding  Debugging  Testing.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
CSCI-235 Micro-Computer Applications
Structured Programming
Designing and Debugging Batch and Interactive COBOL Programs
Chapter 3 The DATA DIVISION.
An Introduction to Structured Program Design in COBOL
Chapter 14 Sorting and Merging.
Programming Logic and Design Eighth Edition
Presentation transcript:

Chapter 1 1-1

To familiarize you with  Why COBOL is a popular business-oriented language.  Programming practices and techniques  History of COBOL  Use of the current ANSI standard versions of COBOL  Four divisions of a COBOL program 1-2

 Computer Programming: An Overview  Applications Program Development Process  Nature of COBOL  History of COBOL and the ANS Versions 1-3

 Techniques for Improving Program Design  Sample Programs  Entering and Running a COBOL Program on Your Computer ◦ This is particular to our system ◦ We’ll be using the “Alpha” which is a VAX ◦ Telnet into it, you’ll love the editor. 1-4

Machine language  Only language computer understands  All programs executed on computer must be in machine language  Machine language programs difficult to write 1-5

Symbolic language (like COBOL)  English-like languages used to write programs  Easier than writing programs in machine language  Must be translated or compiled into machine language to run on computer 1-6

1. Determine Program Specifications 2. Design Program Using Program Planning Tools 3. Code and Enter Program 4. Compile Program 5. Test Program 6. Document Program 1-7

Systems analysts, users and programmers develop specifications Specifications include: Description of input and output data Step-by-step processing required to convert input to output 1-8

Record layout forms describe format of input and output data  Data names of each data item in record  Location of each data item in record  Size of each data item  Number of decimal positions (for numeric data items)  Note that this is different than what you are used to in C++ 1-9

Printer spacing charts describe  Spacing  Layout of printed output  Heading, detail, total lines  Error messages 1- 10

Program planning tools used to map out structure and logic of program  Flowcharts use block diagrams to represent logic  Pseudocode uses English-like statements  Hierarchy charts show relationships among sections of program 1- 11

 Programmer writes and enters program into computer  Program written in symbolic language (like COBOL)  Called source program  You all already know this 1- 12

Compiler is program that  Checks source program for rule violations  Translates source program into object program  Next class we’ll try this out Source program in symbolic language Object program in machine language Translated by compiler

 Test or debug program to ensure it contains no errors  Check for two types of errors ◦ Compile-Time Errors ◦ Execution Errors 1- 14

 Errors detected by compiler during translation from COBOL to machine language  Detects violations of programming rules ◦ Misspelled reserved words ◦ Missing punctuation  Also called syntax errors 1- 15

 Detected when program is run  Logic error causes incorrect output ◦ Sequence of instructions incorrect ◦ Wrong instruction coded  Run-time error if computer cannot execute instruction ◦ Attempt to divide by zero ◦ Attempt to read a file that cannot be found 1- 16

 Desk checking  Correcting syntax errors  Program walkthroughs  Executing the program 1- 17

 Documentation - formal set of procedures and instructions to specify how to use program  Written for ◦ Those working with output ◦ Computer operators who run program ◦ Maintenance programmers who make modifications to program  This was a big part of the design of COBOL, Self documenting code 1- 18

 Business-oriented language  Standard language  English-like language  Relatively easy to understand 1- 19

 Distinct Features of COBOL  The language is simple  No pointers  No user defined types  No user defined functions  ‘Structure like’ data types  File records are also described with great detail, as are lines to be output to a printer  COBOL is self documenting 1- 20

 Advantages  -Simple  -Portable  -Maintainable  Disadvantages  -very wordy  -very rigid format  -not designed to handle scientific applications 1- 21

 Developed in 1959 as standard language to meet needs of business  Committee to develop language convened by Department of Defense  Included representatives from academia, business, computer manufacturers 1- 22

 1960s  1968  1974   wide variations in COBOL compilers  first COBOL standard set by American National Standards Institute (ANSI)  second ANSI standard to make COBOL more efficient, standardized  this ANSI standard incorporated structured programming techniques

 1985 currently the most widely used  The book mentions 2008 as the latest standard but looks like 2002 may be  So the book mentions 2008 conventions, seems they work on our compiler

Likely to remain important language  Older COBOL programs need to be updated  Still used by many for new program development  Mostly maintaining existing code, that’s why you’re here

 About 200 billion lines of COBOL source code in use  New lines added each year  Used by many application programmers in medium to large U.S. companies  How about the Y2K Problem? 1- 26

Two techniques used to develop programs that are easier to understand, test, debug and modify  Structured Programming  Top-Down Programming 1- 27

 Eliminates use of GO TO statements ◦ Allowed skipping to different sections of program without returning to starting point  Program logic easier to follow with "GO- TO-less" programming 1- 28

Program divided into paragraphs  Main paragraph or module controls logic flow using PERFORM statements  Main module "performs" other modules when instructions in that module required  Each module can be written and tested independently of others 1- 29

 Another technique to make programs easier to understand, test, debug and modify  Develop program like term paper ◦ Develop outline first ◦ Add details for each of main steps ◦ Add further refinement for more complex steps ◦ Use of stubs For COBOL program  Code main modules or routines first  Code intermediate modules next  Details deferred to minor modules and coded last 1- 30

 Cobol suited for developing both types of programs Interactive programs  Accept input data from keyboard  Input data processed immediately  Output (results) displayed on screen immediately 1- 31

Batch programs  Process large volumes of input at periodic intervals  Input data read in from files  Output written to files 1- 32

 Every COBOL program contains up to four separate divisions in the following order: IDENTIFICATION DIVISION ENVIRONMENT DIVISION DATA DIVISION PROCEDURE DIVISION Specific to COBOL 1- 33

 IDENTIFICATION DIVISION ◦ Identifies program to operating system ◦ Provides documentation about program  ENVIRONMENT DIVISION ◦ Defines file-names ◦ Describes devices used to store them ◦ Not included in fully interactive programs 1- 34

 DATA DIVISION ◦ Describes input and output format of data in files ◦ Defines any constants and work areas  PROCEDURE DIVISION ◦ Contains instructions to read input, process it and create output 1- 35

 Purpose ◦ to compute employee WAGES  Input from keyboard ◦ HOURS and RATE  Processing ◦ compute WAGES as HOURS x RATE  Output displayed on screen ◦ WAGES  Sample on Page 17 of book 1- 36

1- 37 IDENTIFICATION DIVISION. PROGRAM-ID. WAGES1. DATA DIVISION. WORKING-STORAGE SECTION. 01 HOURS PIC RATE PIC 99V WAGES PIC MORE-DATA PIC XXX VALUE 'YES'. PROCEDURE DIVISION. 100-MAIN. PERFORM UNTIL MORE-DATA = 'NO' DISPLAY 'ENTER HOURS AS A TWO DIGIT NUMBER' ACCEPT HOURS DISPLAY 'ENTER RATE IN NN.NN FORMAT (2 DECIMAL DIGITS)' ACCEPT RATE MULTIPLY RATE BY HOURS GIVING WAGES DISPLAY 'WAGES ARE ', WAGES DISPLAY 'IS THER MORE DATA (YES OR NO)?' ACCEPT MORE-DATA END-PERFORM STOP RUN.

 IDENTIFICATION DIVISION ◦ One required entry, PROGRAM-ID ◦ Names the program  DATA DIVISION ◦ Describes and defines storage for all data ◦ Data defined in WORKING-STORAGE SECTION for interactive program 1- 38

 Keyed input fields (HOURS, RATE)  Output fields (WAGES)  Other fields used for processing (MORE- DATA) 1- 39

 01 level begins definition of each field  PICTURE or PIC clause describes ◦ Type of data  Numeric (PIC 9)  Nonnumeric (PIC X) ◦ Size of field - determined by number of 9’s or X’s 1- 40

 RATE with PIC 99V99 includes V to show assumed decimal point position  User enters data with decimal point ◦ Program uses V to align data  WAGES includes actual decimal point ◦ Shown when value displayed on screen 1- 41

 MORE-DATA with PIC XXX is nonnumeric field  Assigned initial contents of YES by use of VALUE clause  Value must be in quotation marks since MORE-DATA is nonnumeric field 1- 42

 Set of instructions to be executed by program  Organization of instructions planned before coding begins  Pseudocode, an English-like description of program instructions, used for planning  Describes program logic and order in which instructions will be executed 1- 43

 PROCEDURE DIVISION includes one paragraph 100-MAIN  List of instructions that follow make up paragraph  Period follows last statement in paragraph (STOP RUN.)  Main processing controlled by PERFORM … END-PERFORM loop 1- 44

 Repeats set of instructions as long as user enters YES in response to prompt "IS THERE MORE DATA (YES/NO)?"  MORE-DATA initially contains YES so instructions in loop executed first time 1- 45

 When user enters NO as response ◦ MORE-DATA set to "NO" and loop ends  After loop, STOP RUN is executed, ending program 1- 46

Statements in loop executed in order they are listed  DISPLAY displays value in quotes or value of field on screen  ACCEPT stores value user enters from keyboard in field  MULTIPLY performs calculation to find WAGES 1- 47

 In batch mode, data comes from input file instead of keyboard  Data for each employee stored in a record in file on disk  Employee name, hours and rate data called fields  Page

 Calculated results (Wages) stored in file instead of displayed on screen  For each input record ◦ Record created and stored in output file ◦ Includes employee name, hours, rate and computed wages ◦ File intended for printing so spacing added between fields for readability 1- 49

 All four divisions included for batch programs  IDENTIFICATION DIVISION first with required PROGRAM-ID paragraph  ENVIRONMENT DIVISION ◦ INPUT-OUTPUT SECTION assigns input and output files to specific devices 1- 50

 FILE SECTION describes format of input and output files  Fields in records described using PICTURE clause  Decimal point not stored in input records ◦ Use V for implied decimal for alignment  Use actual decimal point for fields in output record so it is printed 1- 51

 Contains instructions to be executed by computer  Instructions executed in order they appear  Includes two paragraphs with period at end of each 1- 52

 OPENs files to be used by program  Repeatedly READs in records (PERFORM … END-PERFORM) until there are no more  Calls second paragraph 200-WAGE-ROUTINE to process each record  CLOSEs files after all records read  Ends program (STOP RUN) 1- 53

 Reads one record into program storage area  Record must be in storage to use it  Takes one of two actions depending on whether record was read 1- 54

 PERFORM instruction after NOT AT END executed when record read ◦ Statements in paragraph 200-WAGE-ROUTINE executed to process record  If no more records to be read, MOVE instruction after AT END executed ◦ 'NO ' moved to ARE-THERE-MORE-RECORDS, ends loop 1- 55

 First MOVE initializes PRINT-REC to blanks  Then MOVEs name, hours, wages to output fields  Calculates WAGES with MULTIPLY statement, MOVES it to output field  WRITEs data in employee output record to print file 1- 56

To type in and run a COBOL program on your computer system, you need to know how to:  Log on and off of the computer  Name COBOL files on the computer  Use a text editor to key in, modify and save files  Compile a COBOL source program to translate it into machine language  Link or load the object program  Run the object program 1- 57

 The Nature of COBOL ◦ English-like language ◦ Used widely for business programming ◦ With new standard coming out soon, it is likely to remain important language 1- 58

COBOL programs divided into four divisions  IDENTIFICATION DIVISION identifies program to operating system  ENVIRONMENT DIVISION required for batch programs that operate on files  DATA DIVISION defines formats for all input, output and work areas needed ◦ FILE SECTION required for batch programs that operate on files ◦ WORKING-STORAGE SECTION for work fields or fields used in interactive programs 1- 59

 PROCEDURE DIVISION ◦ Contains instructions to process input and produce output ◦ Divided into paragraphs or modules 1- 60