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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started