1. Write a method populateWithSquares that takes an array of ints as its lone input. It does not return anything, but the array will be changed so that its contents are numbers, where the element at position k will be k2.

2. Write printArray() to print out the contents of the array to verify that populateWithSquares is doing what you want.

Here is some code to get you started:

public static void main(String[] args) {
    int[] nums = new int[9];     // 9 is arbitrary--use some other number if you like!
    populateWithSquares(nums);
    printArray(nums);
}

public static void populateWithSquares(int[] nums) {
    // You write code here
}

public static void printArray(int[] nums) {
    // You write code here, too
}

3. Write a method sumInts that takes an array of ints as its input and returns their sum.

Example:

int[] nums = { 1, 2, 5, 4, 3 };

System.out.println(sumInts(nums));  // prints 15

4. Write a method swap that takes an array of ints and two indices (also ints) as its inputs. It does not return anything, but it switches the positions of the contents of the array at the two indices,

Example:

int[] nums = { 1, 2, 5, 4, 3 };
printArray(nums);   // prints 1, 2, 5, 4, 3
swap(nums, 2, 4);
printArray(nums);   // prints 1, 2, 3, 4, 5