Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your task (in the Main) is to make a 2D Array of a random dimension (5-10). Both dimensions should be the same. You should make

Your task (in the Main) is to make a 2D Array of a random dimension (5-10). Both dimensions should be the same. You should make a method to fill in the array with random values from 10-100.

Write the following methods, including any parameters needed:

  • search() - linear search on the 2D array using an enhanced for-loop to find the minimum value in the array, returning the minimum value
  • sum() - using a column-major traversal, find the sum of all values in the array and return
  • countEven() - count the number of elements in the two dimensional array that are even values
  • countOdd() - count the number of elements in the two dimensional array that are odd values
  • print() - print the array using any looping method

Here is your main method:

public static void main(String [] args) { // Create the 2D array called twoArray // Assign random values from 10 - 100 in the array // Printing the array System.out.println("Original: "); print(twoArray); System.out.println("Finding min " + search(twoArray)); int sum = sum(twoArray); // Calculate and store the sum of the entire array System.out.println(" The sum of the entire array: " + sum); System.out.println(" Even count: " + countEven(twoArray)); System.out.println(" Odd count: " + countOdd(twoArray));}

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions