|
|
|
|
|
|
|
A program needs data on which to operate. We have been writing all of the data values in the program itself, in literal and named constants. If this were the only way we could enter data, we would have to rewrite a program each time we wanted to apply it to a different set of values. In this chapter, we look at ways of entering data into a program while it is running. |
|
|
|
|
|
|
|
|
Once we know how to input data, process the data, and output the results, we can begin to think about designing more complicated programs. We have talked about general problem-solving strategies and writing simple programs. For a simple problem, it's easy to choose a strategy, write the algorithm, and code the program. But as problems become more complex, we have to use a more organized approach. In the second part of this chapter, we look at two general methodologies for developing software: top-down design and object-oriented design. |
|
|
|
|
|
|
|
|
Getting Data into Programs |
|
|
|
|
|
|
|
|
One of the biggest advantages of computers is that a program can be used with many different sets of data. To do so, we must keep the data separate from the program until the program is executed. Then instructions in the program copy values from the data set into variables in the program. After storing these values into the variables, the program can perform calculations with them (see Figure 4-1). |
|
|
|
|
|
|
|
|
The process of placing values from an outside data set into variables in a program is called inputting. In widely used terminology, the computer is |
|
|
|
|
|
|
|
|
Figure 4-1
Separating the Data from the Program |
|
|
|
|
|