Modify a text file: $/array-practice.html
$/array-practice.html
Array Practice
Create a (global) array of float[], and a variable "
wbig
" to contain the index of the biggest one (if known).
The setup() method should fill the array with random values (0.0 to 100.0) and set
wbig
to -1.
The draw() method should always display the array elements; if the biggest element has been found, display its value.
In the keyPressed() handler, handle the following keys:
When the
'f'
key is pressed, fill the array with random values (0.0 to 100.0) and set
wbig
to -1.
When the
'b'
key is pressed, find the biggest element, and set
wbig
.
When the
'm'
key is pressed, move the biggest element to the end (swapping, to retain all values).
When the
'S'
key is pressed, sort the entire array (in ascending order).
Now, add buttons to be clicked on, instead of using keys. Buttons should be labelled:
FILL
BIG
MOVE
SORT