Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions

Question

3. Provide two explanations for the effects of mass media

Answered: 1 week ago