CST 112
Project 5
- Declare a (global) array of float[] and name it with your initials (2 or 3, all in lower-case).
Also declare a global variable named "wbig" to contain the index of the biggest element in the array (if known).
- The setup() method should fill the array with twenty 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, then 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 'n' key is pressed, move the next-biggest (second-largest) value into the next-to-last element (swapping, to retain all values).
- (Just think about how you might do this for the third-biggest value -- but don't code this!)
- When the 's' key is pressed, sort the entire array (in ascending order).
- When the 'd' key is pressed, replace all duplicate values with zero
(but do not sort the array again).
- OPTIONAL:
Add buttons to be clicked on, instead of using keys.
Buttons should be labelled:
- FILL
- BIG
- MOVE
- NEXT
- SORT
- DUPS
To illustrate SOME of the above specifications,
a working copy ("jar" file) of a similar program
is available at this URL:
Note that your array should contain twenty values, and there are other tasks to be performed.