Prev | Current Page 134 | Next

Carl Reynolds and Paul Tymann

"Schaum's Outline of Principles of Computer Science"

4
Execution starts at main. The main program creates an array of four floating-point numbers, and then it
prints the character string "Std. dev. = ", followed by the number returned from the stdDev routine when
stdDev is passed the array of four numbers. The code in stdDev follows our pseudocode above, using a for
loop to iterate through all the numbers in the array that the main passed to stdDev.
Java was designed to be an object-oriented language, and object orientation provides even more sophisticated
ways to create modules of code than a strictly procedural language like FORTRAN offers. Nevertheless, one
can program procedurally in Java, as we have done above.
Procedural programming captures standard solutions to computational problems in blocks of code that
can be accessed by name, that are reusable by means of a standard set of inputs (arguments??”the variables
passed into the routine), and that return a standard set of outputs. Notice, too, that variables have procedure
???scope;??? variables that are declared within the procedure, like sum and sumSquares, and are visible only
within the procedure. This helps avoid confusion regarding the variables being used, and thus adds to program
reliability.


Pages:
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
mieszkania szczecin Wakacje w Chorwacji ubrania pieniny noclegi Gorsety