Held: Tuesday, March 3, 1998
main routines that describe how to
build a program from classes.
Work on computing assignment 6.
type[] name = new type[size];
stuff,
you would write
double[] stuff = new double(5);
type[] name = { val1, val2, ...,
valn };
double[] stuff = {3, 2, 6, 5};
name[index]
stuff with
stuff[3]
i held the value 3, then we could get
element 3 of the stuff with
stuff[i]
name.length
public double sum(double[] stuff)
{
double total = 0; // The total of the numbers in stuff
int i; // A counter variable for stepping through
// the array
// Step through the array, adding each subsequent value
for(i = 0; i < stuff.length; i = i + 1) {
total = total + stuff[i];
}
// Return the total value
return total;
} // sum
Work on computing assignment 7.
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
Source text last modified Thu May 7 10:53:53 1998.
This page generated on Thu May 7 10:58:49 1998 by SiteWeaver.
Contact our webmaster at rebelsky@math.grin.edu