Assignment 2

8
IFS 210 1 Assignment 2 Keyboard Input and Screen Display ––––––––––– Interactive Programming

description

Assignment 2. Keyboard Input and Screen Display ––––––––––– Interactive Programming. Program Types. Batch Input files Output files No interaction with the users Interactive User types in data at the keyboard Data is displayed on the screen. The Output Screen. - PowerPoint PPT Presentation

Transcript of Assignment 2

Page 1: Assignment 2

IFS 210 1

Assignment 2

Keyboard Input and Screen Display

–––––––––––

Interactive Programming

Page 2: Assignment 2

IFS 210 2

Program Types

Batch Input filesOutput filesNo interaction with the users

InteractiveUser types in data at the keyboardData is displayed on the screen

Page 3: Assignment 2

IFS 210 3

The Output Screen

Used for low-volume outputWarning messages Special conditions encountered in the data

Accomplished with the DISPLAY statementDISPLAY {identifier / literal} …DISPLAY PR-PATRON-NAMEDISPLAY “Sample Literal”DISPLAY “Patron Name: ”, PR-PATRON-

NAME

Page 4: Assignment 2

IFS 210 4

The DISPLAY Statement

Normally, after a DISPLAY statement is executed, the cursor will advance to the start of the next line.

The WITH NO ADVANCING phrase causes the cursor to remain where it is, following the last position of the display elements.

This is useful when your program queries the user and waits for a response.

Page 5: Assignment 2

IFS 210 5

The ACCEPT Statement

Allows the user to enter data from the keyboard into the program.Example: ACCEPT WA-PAY-RATEThe program stops and waits for the user to enter data with keyboard and press <enter>.The value typed by the user is stored in the variable WA-PAY-RATE

Page 6: Assignment 2

IFS 210 6

An Interactive Program(p. 115-)

Display an opening announcement This described to the user the purpose of the

program and provides an option to continue

Prompt the user for input data (two lines) The name of the field The picture of the field (string of X’s or 9’s)

Finally, the user is asked whether he wishes to enter another record.

Page 7: Assignment 2

IFS 210 7

Output Files

What happened to your EARNINGS.RPT file when you ran the program (Assignment 1) a second time?

Was the new report appended to the end of the file, or was the file re-written?

Page 8: Assignment 2

IFS 210 8

Pseudocode (EMPADD)000-create-patron-file.

1. PERFORM 100-display-announce-screen

2. OPEN patron file (extend mode)

3. PERFORM UNTIL do-not-continue

a. PERFORM 200-accept-patron-record

b. WRITE patron record

c. Query user about continuing

4.Close patron file

5.Stop run

100-display-announce-screen.

1. DISPLAY description of program

2. Query user about continuing

200-accept-patron-record.

1. DISPLAY and ACCEPT the fields