1 / 8

Assignment 2

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.

kurtmorris
Download Presentation

Assignment 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Assignment 2 Keyboard Input and Screen Display ––––––––––– Interactive Programming

  2. 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

  3. 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

  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.

  5. 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

  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.

  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?

  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

More Related