Create an manages a 2d array of ints

Assignment Help Computer Engineering
Reference no: EM132175589

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

getSmallest() Gets the smallest integer in the array

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

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

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

Use the following file:

Util2DTester.java

/** * Tester for Util2D class. * * @author Kathleen O'Brien */ 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"); } }

Reference no: EM132175589

Questions Cloud

Basis for moral decision-justifying a course of action : What potential issues could arise when using a religious authority (for instance, the gods or God) as a basis for moral decision/justifying a course of action?
Review the problems of the coherent waves : Two coherent sources of radio waves, A and B, are 5.00 metersapart. Each source emits waves with wavelength 6.00 meters.
Show how the clock input is connected to the devices : Show how the clock input is connected to the devices. Draw the circuit clearly.
Contrast the functionalist and conflict perspectives : Contrast the functionalist and conflict perspectives on culture and explain three ways in which social networks in our society are changing due to the internet.
Create an manages a 2d array of ints : 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.
Discuss two specific ways : Discuss two specific ways that technology is changing the face of the workplace.
Becoming more secularized or more fundamentalist : Do you believe the united states is becoming more secularized or more fundamentalist? comparing your generation to that of your parents or grandparents
Argue against striving for this form of equality : What is "equality of condition," and why did Thomas Malthus argue against striving for this form of equality?
Argument anticipate the free rider problem : Why, according to Adam Ferguson and John Miller, is inequality necessary? In what way does their argument anticipate the "free rider problem"?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Write a program that reads a square array of integers

Write a program that reads a square array of integers and determines whether or not it is a magic square.

  Determine which algorithm runs faster

Determine which algorithm runs faster. Show your work; you will need to compute a maximum common point after which one algorithm is better.

  Write a method heading that accepts the values as input

Given the following task, which would be the most appropriate method heading? Write a method heading that accepts these values as input for display purposes.

  Write a program that calculates a tip

Write a program that calculates a tip according to the diner's satisfaction as Ask for the diners' satisfaction level using these ratings.

  Develop and test an html document that collects information

Develop and test an HTML document that collects the following information from the user: last name, first name, middle initial, age and weight.

  You work as the network administrator for a medium-size

you work as the network administrator for a medium-size company. you got to work on a monday morning and as soon as you

  Define trust model and mention some variations of ibis model

List the duties of a PKI. Define a trust model and mention some variations of ibis model discussed in this chapter.

  Prepare data flow diagrams which use only a few symbols

"It is easier to learn to prepare data flow diagrams, which use only a few symbols, than it is to learn to prepare flowcharts, which use a number of different symbols." Discuss.

  What did you like most about taking linux

What did you like most about taking Linux? What are some of the pros and cons you experienced while learning Linux.

  Find if m is a maximum matching in g in worst case

Let G = (V,E) be a weighted graph and let T be a minimum spanning tree of G. The path in T between any pair of vertices v_1 and v_2 must be a shortest path in G.

  Develop functional decomposition diagram to show functions

Develop a high-level use case to represent the application as a whole. Develop a functional decomposition diagram to show all of the functions that the system or application will support.

  What variety of cable will work to make an association

What variety of cable will work to make an association

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd