Question: Write a procedure/method (the syntax for writing a procedure is on page 5 of the Reference Sheet) that creates an array of numbers {1, 2,

Write a procedure/method (the syntax for writing a procedure is on page 5 of the Reference Sheet) that creates an array of numbers {1, 2, 3, 4, 5} with 1 being in the first position and 5 being in the fifth position of the list. Call this procedure "CreateArray". (Note that on the Reference Sheet, arrays are referred to as lists)

Write another procedure/method that reverses the array of numbers so that the values are now {5, 4, 3, 2, 1} in positions 1, 2, 3, 4, 5 respectively. Call this procedure "ReverseArray". (using ReverseArray twice should return the array to the previous order of {1, 2, 3, 4, 5})

Now create your Main procedure/method (another name for MyFirstMethod), and store your name inside a variable called "name". Then use CreateArray and ReverseArray to finish with an array of {5, 4, 3, 2, 1}.

(NOTE: I've attached the reference sheet below).

Write a procedure/method (the syntax for writing a procedure is on page

Instruction Explanation List Operations (continued) Any values in list at indices greater than or equal to i are shifted to the right. The length of list is increased by 1, and value is placed at index i in list. Text: INSERT (list, i, value) Block: INSERT list, i, value Text: APPEND (list, value) Block: APPEND list, value The length of list is increased by 1, and value is placed at the end of list. Text: REMOVE (list, i) Removes the item at index i in list and shifts to the left any values at indices greater than i. The length of list is decreased by 1. Block: REMOVE list, i Evaluates to the number of elements in list. Text: LENGTH (list) Block: LENGTH list Text: PROCEDURE name (parameterl, parameter2, { } Procedures A procedure, name, takes zero or more parameters. The procedure contains programming .) instructions. Block: PROCEDURE name parameteri, parameter2,... instructions Text: PROCEDURE name (parameterl, parameter2, ...) A procedure, name, takes zero or more parameters. The procedure contains programming instructions and returns the value of expression. The RETURN statement may appear at any point inside the procedure and causes an immediate return from the procedure back to the calling program RETURN (expression) } Block: PROCEDURE name parameteri, parameter2,.. instructions RETURN expression

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!