Modifying arrays

In this lab, we will do some exercises in modifying arrays. If you'd like a bit more of a review on arrays, you can return to the array operation lab.

Downloading the project framework

Download ArrayMod.zip, a ZIP file containing a NetBeans project named ArrayMod and unZIP this project into your csci/201 directory. Try to make your Projects panel look something like the following picture before continuing.
ArrayMod Projects

Open, compile, and run the ArrayMod class. You should notice some fairly strong similarities between the ArrayOp and ArrayMod classes.

Modifying arrays

Examing the present code

ArrayMod has internal classes which are supposed to modify the elements of an array. Right now there is one complete class. Your job is to add five more to solve the problems shown in the table below. Use the solution set generator on the right to check your answers.

Most of these tasks are fairly simple. If you are writing a lot of code, you may be off the right track.

Class Name Operation performed in TestFunc
MyClass1 Add one to each element of the array.
MyClass2 Multiply each element by three.
MyClass3 Set all array elements to zero.
MyClass4 Set the i'th array element to i.
MyClass5 Reverse the array.
MyClass6 Relax the array, that is, set each element to the average of its two surrounding neighbors, except for the first and last elements which are left unchanged.

If the last Java class stresses you, ask your lab instructor about relaxation.

Again, when you are done, show your lab instructor the output of your program.