ICS 3M Array Assignment

Marks: 20

 

In this assignment you will be developing a number of functions and procedures. Save all of your work and print it out. Marks will be deducted for poor comments, and poor style.

 

1. Create a function called occurrences that takes two parameters, an array of integers and an integer, it will result the number of times the number is in the array. Save as array1.t

 

2.  Write a function called median that takes an array of integers and returns the median (the number that would be in the middle if they were in order). Save as array2.t

 

3. Write a function called highest that returns the highest value in an array of integers. Save as array3.t

 

4.  Write a procedure called topHalf that takes an array of integers and outputs to the screen all of the numbers that are above the average (mean) of the group. Save as array4.t

 

5. Write a procedure called fillGrid that takes a two-dimensional array of 8x8 integers, and fill the grid with random values from 0-100. Save as array5.t

 

6. Write a program that draws 20 10x10 boxes randomly on the screen, then erases them in reverse order. Delay 100ms between each drawing and erasing of boxes. Save as array6.t

 

7. Write a procedure called follow that allows the user to use the mouse to click on the screen. When they click on the screen it draws a circle with radius 10, and a line to the last spot clicked (no line if it’s the first click).When the user clicks for the fourth time the procedure will erase the first circle and line. From then on, whenever a new circle and line are drawn the oldest one will be erased. The procedure will end when the user clicks on both buttons at once. The colour of all the drawing is supplied by a single integer parameter. Save as array7.t