Question: A Java Problem. Util2D creates an manages a 2d array of ints. It has a constructor that takes a 2d array as a parameter and

A Java Problem. Util2D creates an manages a 2d array of ints. It has a constructor that takes a 2d array as a parameter and assigns it to the instance variable. You write the whole class

Provide the constructor

Provide these methods

1. getSmallest() Gets the smallest integer in the array

2. numberOfEvenInColumn(int column) Gets the number of even integers in the specified column. Remember both positive and negative numbers can be even.

3. last() Gets the element in the last column of the last row

4. contains(int target) Returns true if the target is in the array, otherwise false

------------------------------------------------------------------------------------------------------------

Util2DTester.java

public class Util2DTester { public static void main(String[] args) { int[][] numbers = { {-5, 8, 6, 3, 11}, {3, -6, -2, 5, -9}, {1, 2, 5, 7, 6} }; Util2D util = new Util2D(numbers); System.out.println("Smallest: " + util.getSmallest()); System.out.println("Expected: -9"); System.out.println("Even in column#1: " + util.numberOfEvenInColumn(1)); System.out.println("Expected: 3"); System.out.println("Even in column#0: " + util.numberOfEvenInColumn(0)); System.out.println("Expected: 0"); System.out.println("Last: " + util.last()); System.out.println("Expected: 6"); System.out.println("Contains: " + util.contains(8)); System.out.println("Expected: true"); System.out.println("Contains: " + util.contains(15)); System.out.println("Expected: false"); int[][] numbers2 = { {5, 3, 2, 4}, {6, 1, 7, 8} }; util = new Util2D(numbers2); System.out.println("Smallest: " + util.getSmallest()); System.out.println("Expected: 1"); System.out.println("Last: " + util.last()); System.out.println("Expected: 8"); } } 

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!