Question: Lab Description 1) Write a Smalltalk script in the playground that computes and prints the average of all the even integers in an array. You

 Lab Description 1) Write a Smalltalk script in the playground thatcomputes and prints the average of all the even integers in an

Lab Description 1) Write a Smalltalk script in the playground that computes and prints the average of all the even integers in an array. You may use any loop style you like. Assume nothing about the contents of the array; It might contain any mixture of types or objects. However, only those elements that are integers, and even, should contribute to the average. Create your own heterogeneous array to test your script. 2) Write a Smalltalk script in the playground that instantiates an empty OrderedCollection object, generates 20 random integers between 0 and 15 (inclusive), and adds those integers to the OrderedCollection. You should then print the contents of the OrderedCollection, as well as the number of unique elements in the OrderedCollection. Hint: Smalltalk has a class called Random which implements the function next. It returns a number in the range [l 0 1]. 3) Write a Smalltalk script in the playground that finds and prints the largest, odd number in an array of integers. You may use any loop style you want, but in your loop, you should use a BlockClosure to test if the number is odd. Create your own array of integers to test your script

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!