|
|
|
|
|
|
|
In programs that use large amounts of data, this method saves the user keystrokes and time. However, it also makes it easier for the user to enter values in the wrong order. |
|
|
|
|
|
|
|
|
Prompts are not the only way in which programs interact with users. It can be helpful to have a program print out some general instructions at the beginning (Press RETURN after typing each data value. Enter a negative number when done.). When data is not entered in the correct form, a message that indicates the problem should be printed. For users who haven't worked much with computers, it's important that these messages be informative and friendly. The message |
|
|
|
|
|
|
|
|
ILLEGAL DATA VALUES!!!!!!! |
|
|
|
|
|
|
|
|
is likely to upset an inexperienced user. Moreover, it doesn't offer any constructive information. A much better message would be |
|
|
|
|
|
|
|
|
That is not a valid part number.
Part numbers must be no more than four digits long.
Please reenter the number in its proper form: |
|
|
|
|
|
|
|
|
In Chapter 5, we introduce the statements that allow us to test for erroneous data. |
|
|
|
|
|
|
|
|
Noninteractive Input/Output |
|
|
|
|
|
|
|
|
Although we tend to use examples of interactive I/O in this text, many programs are written using noninteractive I/O. A common example of noninteractive I/O on large computer systems is batch processing. Remember that in batch processing (Chapter 1), the user and the computer do not interact while the program is running. This method is most effective when a program is going to input or output large amounts of data. An example of batch processing is a program that inputs a file containing semester grades for thousands of students and prints grade reports to be mailed out. |
|
|
|
|
|
|
|
|
When a program must read in many data values, the usual practice is to prepare them ahead of time, storing them into a file. This allows the user to go back and make changes or corrections to the data as necessary before running the program. When a program is designed to print lots of data, the output can be sent directly to a high-speed printer or another disk file. After the program has been run, the user can examine the data at leisure. In the next section, we discuss input and output with disk files. |
|
|
|
|
|