CS 313001Day 3 - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

CS 313001Day 3

Description:

8 SELECT STUDENT-FILE ASSIGN TO SYSIN. 9 ORGANIZATION IS LINE SEQUENTIAL. ... Student Assignments. You will have mastered the material in Chapter 1 when you can: ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 14
Provided by: haz3
Category:
Tags: 313001day | assign

less

Transcript and Presenter's Notes

Title: CS 313001Day 3


1
CS 313-001 Day 3
  • Chapter 1
  • Introduction to COBOL and Program Development

2
Todays Outline
  • Handouts
  • Roll
  • CoE Labs Log in
  • Lab Materials
  • Chapter 1 Review pages 1-7
  • Continue with Chapter 1

3
REVIEW
4
Structured Programming
  • Structured programming is a methodology by which
    all program logic can be developed by using and
    combining just three basic logic control
    structures---
  • A) sequence
  • B) selection
  • C) iteration

5
Logic control structure
  • A logic control structure is a way in which all
    program logic can be executed.

6
Divisions of a COBOL Program
  • IDENTIFICATION DIVISION.
  • ENVIRONMENT DIVISION.
  • DATA DIVISION.
  • PROCEDURE DIVISION.

7
The First COBOL Program
Identification Division
1 IDENTIFICATION DIVISION.2 PROGRAM-ID. SENIOR.3
AUTHOR. ROBERT GRAUER.45 ENVIRONMENT
DIVISION.6 INPUT-OUTPUT SECTION.7 FILE-CONTROL.
8 SELECT STUDENT-FILE ASSIGN TO
SYSIN9 ORGANIZATION IS LINE SEQUENTIAL.10
SELECT PRINT-FILE ASSIGN TO SYSOUT11 ORGANIZATIO
N IS LINE SEQUENTIAL.1213 DATA
DIVISION.14 FILE SECTION.15 FD
STUDENT-FILE16 RECORD CONTAINS 43
CHARACTERS17 DATA RECORD IS
STUDENT-IN.18 01 STUDENT-IN.19 05
STU-NAME PIC X(25).20 05 STU-CREDITS PIC
9(3).21 05 STU-MAJOR PIC X(15).22
Environment Division
Data Division
8
The First COBOL Program (continued)
Data Division
23 FD PRINT-FILE24 RECORD CONTAINS 132
CHARACTERS25 DATA RECORD IS
PRINT-LINE. 26 01 PRINT-LINE PIC
X(132).27 28 WORKING-STORAGE SECTION. 29 01
DATA-REMAINS-SWITCH PIC X(2) VALUE
SPACES.30 31 01 HEADING-FILE.32 05
FILLER PIC X(10) VALUE SPACES. 33 05
FILLER PIC X(12) VALUE STUDENT NAME.34 05
FILLER PIC X(110) VALUE SPACES.35 36 01
DETAIL-LINE. 37 05 FILLER PIC X(8) VALUE
SPACES.38 05 PRINT-NAME PIC X(25). 39
05 FILLER PIC X(99) VALUE SPACES.40
9
The First COBOL Program (continued)
41 PROCEDURE DIVISION. 42 PREPARE-SENIOR-RE
PORT. 43 OPEN INPUT STUDENT-FILE 44
OUTPUT PRINT-FILE. 45 READ
STUDENT-FILE 46 AT END MOVE
NO TO DATA-REMAINS-SWITCH47
END-READ. 48 PERFORM
WRITE-HEADING-LINE. 49 PERFORM
PROCESS-RECORDS50 UNTIL
DATA-REMAINS-SWITCH NO.51 CLOSE
STUDENT-FILE52 PRINT-FILE.53
STOP RUN.54 55 WRITE-HEADING-LINE.
56 MOVE HEADING-LINE TO PRINT-LINE.57
WRITE PRINT-LINE.58 59
PROCESS-RECORDS.60 IF STU-CREDITS gt
110 AND STU-MAJOR ENGINEERING61
MOVE STU-NAME TO PRINT-NAME62
MOVE DETAIL-LINE TO PRINT-LINE63
WRITE PRINT-LINE64 END-IF.65
READ STUDENT-FILE66 AT END MOVE
NO TO DATA-REMAINS-SWITCH67 END-READ.
Procedure Division
10
Rules for the COBOL Coding Form
COLUMN EXPLANATION AND USE
Optional sequence numbers If this field is
coded, the compiler performs a sequence check on
incoming COBOL statements by flagging any
statements out of order. Although some
commercial installations encourage this option,
we advise against it, especially since you are
entering your own programs, and the more you
type, the more chance for error. An asterisk in
column 7 indicates a comment, while a hyphen is
used for the continuation of nonnumeric literals
(described further on page 180). Comments may
appear anywhere in a program they are shown on
the source listing but otherwise ignored. Known
as the A margin Division headers, section
headers, paragraph names, FDs, and 01s all
begin in the A margin. Known as the B margin all
remaining entries begin in or past column 12.
COBOL permits considerable flexibility here, but
individual installations have their own
requirements. We, for example, begin PICTURE
clauses in the same column, for example, column
37, for better readability. (We shall discuss
this further in Chapter 7.) Program
identification a second optional field, which is
ignored by the compiler. Different installations
have different standards regarding use of this
field.
1-6 7 8-11 12-72 73-80
11
CHAPTER 1
  • Chapter Summary
  • Key Terms
  • Student Assignments

12
You will have mastered the material in Chapter 1
when you can
  • Identify the advantages and disadvantages of
    COBOL
  • Understand the difference between record
    input/output and stream input/output
  • List the steps required by the programming
    process
  • Name the logic structures used in a structured
    program

13
  • Describe the top-down design and top-down
    programming
  • Name the four divisions of a COBOL program
  • Specify the purpose of each COBOL division
  • Identify valid COBOL words
  • Describe the format of a line of COBOL source code
Write a Comment
User Comments (0)
About PowerShow.com