Problems

  1. Reverse (15 points)

    Write a static method which takes an array of ints as its argument, and reverses the order of the elements in the array. That is, the first and last elements are switched, the second and second last elements are switched, etc. For example, this method should change the array [1, 2, 3, 4] to the array [4, 3, 2, 1].

    Write a driver file to test your method. It should call your method with at least three different inputs.

  2. Medal Count (15 points)

    A version of the classAthlete, which we wrote in class, is available here. Write a static method which takes an array of Athletes as its argument, and returns the total number of medals won by all athletes stored in the array. Change the package of Athlete.java if needed.

    Write a driver file to test your method. It should call your method with at least three different inputs.

  3. Symmetric Matrix (25 points)

    Write a static method which takes a 2-dimensional array of type int, which represents a matrix, as its argument, and returns true if the matrix is symmetric and false otherwise. A matrix is symmetric if the entry at row i and column j is the same as the entry at row j and column i for each i and j. The diagonal entries (i.e. entries with the same row and column) can be any number.

    Write a driver file to test your method. It should call your method with at least three different inputs.

Submitting Your Problem Set

You should submit all problems for grading by the deadline (see class schedule for date). To submit a program, you need to demonstrate (during office hours or lab) your program and explain how it works.