Question: this SHOULD be in PHARO Smalltalk PLEASE Preamble This lab gives you more practice using loops and branching in Smalltalk. Lab Description 1) Write a
this SHOULD be in PHARO Smalltalk PLEASE
Preamble This lab gives you more practice using loops and branching in Smalltalk. Lab Description 1) Write a program that computes the average of all the even integers in an array. Write the program in two ways, using a whileTrue loop and a do: loop. Test your program with the following inputs: arr := #(84 45 54 456 456 33 34) arr := #(706 348 435 430 278 736 803 683 248 873) arr := #(323 274 711 918 772 727 13 724 593 215) 2) Write a program that builds an array of length n = 500 and fill it with random integers between 0 and 1000. Hint: Smalltalk has a class called Random which implements the function next. It returns a number in the range [0 1]. 3) Write a program that finds the largest odd number in an array. In your loop, use a BlockClosure to test if a number is odd. Test you program with the arrays in Question 1. 4) Write a program that prints a diamond of a given side length using the characters'and 1'. For example, for sidelength = 4 the output should be: Preamble This lab gives you more practice using loops and branching in Smalltalk. Lab Description 1) Write a program that computes the average of all the even integers in an array. Write the program in two ways, using a whileTrue loop and a do: loop. Test your program with the following inputs: arr := #(84 45 54 456 456 33 34) arr := #(706 348 435 430 278 736 803 683 248 873) arr := #(323 274 711 918 772 727 13 724 593 215) 2) Write a program that builds an array of length n = 500 and fill it with random integers between 0 and 1000. Hint: Smalltalk has a class called Random which implements the function next. It returns a number in the range [0 1]. 3) Write a program that finds the largest odd number in an array. In your loop, use a BlockClosure to test if a number is odd. Test you program with the arrays in Question 1. 4) Write a program that prints a diamond of a given side length using the characters'and 1'. For example, for sidelength = 4 the output should be
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
