80 likes | 93 Views
This program allows users to input data using the keyboard and displays it on the screen. It supports low-volume output, warning messages, and special conditions. The program uses the DISPLAY and ACCEPT statements for interactive functionality.
E N D
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 • Used for low-volume output • Warning messages • Special conditions encountered in the data • Accomplished with the DISPLAY statement • DISPLAY {identifier / literal} … • DISPLAY PR-PATRON-NAME • DISPLAY “Sample Literal” • DISPLAY “Patron Name: ”, PR-PATRON-NAME
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.
The ACCEPT Statement • Allows the user to enter data from the keyboard into the program. • Example:ACCEPT WA-PAY-RATE • The 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
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.
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?
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