PROJECT 3: Array of integers

Each function should accept two arguments:

NOTE:   Do not use global variables in these functions; instead, use the arguments, as in the following example:

Here is an example of code that displays an array:
  void show( int[] a, int m ) {
    // Display a list of array elements at (x,y)
    int spacing = 18;
    textSize( 16 );
    for (int j=0; j<m; j=j+1) {
            text( a[j], x, y );
            y = y + spacing;
    }
    return;
  } 

This function returns the sum of the elements:
float sum( int[] a, int m ) {  // Add 'em up!
    // Compute the sum; return the total. // 
    float result=0;
    for (int j=0; j<m; j=j+1) {
            result += a[j];
    }
    return result;
} 


These functions are called

Action Key Button
reset( int a[], int m )
    // Replace all numbers with random values.
r RESET
calc( int a[], int m )
    // Calculate new total and average.
c CALC
next( int a[], int m )
    // Increase each of the numbers by one.
n NEXT
dbl( int a[], int m )
    // Double each of the numbers.
d DOUBLE
half( int a[], int m )
    // Reduce each by half.
h HALF
big( int a[], int m )
    // Move biggest number to end of the array.
    // (Swap elements, to preserve all numbers.)
b BIG
sort( int a[], int m )
    // Sort the entire array.
s SORT

NOTE:   Do not use global values in these functions; use the arguments.


KEYS   The keyPressed() function should have code to call a function when the key is the first letter of that function.

    r	reset()		// Replace with random values.
    c	calc()		// Calculate new sum and average.

    n	next()		// Increase each by one.
    d	dbl()		// Double each of the numbers.
    h	half()		// Reduce each by half.
    b	big()		// Move biggest to end of array.
    s	sort()		// Sort the entire array.

BUTTONS
create buttons with names for each of these,
and add mousePressed() code to call these functions when button is pressed.