Question: 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

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 Programming Questions!