Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java 1/2 80% + 05CING REVISION on 20 arrays Problem 1: Watch the videos posted on B8 on 20 arrays then solve the following questions.

image text in transcribed
image text in transcribed java
1/2 80% + 05CING REVISION on 20 arrays Problem 1: Watch the videos posted on B8 on 20 arrays then solve the following questions. Write the following lava methods and test it in the main() method. 1. Write a method printArray() to display the elements of a two-dimensional array of integers. The array is received as a parameter. public static void printArrayfint 170 are) Create a 2D array in the main method, call it array1, that is 10 rows and 5 columns and print it 2. Write a method fillArray to initialize a two-dimensional array of integers to random values. The Integer array is received as a parameter. The initialization values are generated randomly between a minimum and a maximum value public static void fillArrayfint 10 arr, int min, int max) Fill the array created in 1 (array) with values between 10 and 100 3. Write a method to determine if a two dimensional array is square or not. The method returns true if the number of rows is equal to the number of columns of the 2D array public static boolean isSquare(int (1) arr) Test your method with the created array array: Create another array, call it array that has 5 rows and 5 columns, then fill it and test again 4- Write a method to determine and display the sum of all the values in the primary diagonal of a 2D Integer array. The 2D integer array is received as a parameter to the method public static int sumOfPrimarylint 101 arr) in the main method, get and display the sum of primary for array 5. Write a method to determine and display the sum of all the values in the secondary diagonal of a 20 integer array. The 2D integer atray is received as a parameter to the method public static int sumorSecondaryfint Ular) in the main method, get and display the sum of secondary for array 6 Write a method to find the sum of each row in a 2 dimensional integer array. The return values an array of integer public static int sumofRows in 10 arr) In the main method, et and display the sum of rows for both array and Say2 7. Write a method to find the sum of each columns 2 dimensory. The return array of inters public static Intl sumo Colint 1) in the man methods and play the sum of columns for both way and 2 80% + UAEU College of Information EU United Arab Emirates University Technology 8- Write a method to create a copy of an existing 2D array. The newly created array has the same elements and dimensions of the given array. public static int[] createCopy(int[][] arr) In the main method, test your method by creating a new array that is similar to array2 and call it array3. 9. Write a method to determine if two 2D arrays are equal or not. The method returns true if the two arrays have the same dimensions and the same elements, and false if they have different dimensions or different elements. Use two nested loops and compare the elements one by one. public static boolean areEqual(int(10) arr1, int(10) arr2) In the main method, test your method twice: once with array2 and array3, and once with array2 and array1 10 Write a method to determine if a 2D array is an identity matrix or not. An identity matrix is a square 2D array, where there are 1 in the primary diagonal and everywhere else. public static boolean isidentity(int[)0 arr) Example of an identity matrix: 1000 0100 0010 0001 In the main method, create a new 2D array, call it array4, that has 4 rows and 4 columns, and fill it as an identity matrix. Test your method with array4 and array2 Problem 2

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

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

Recognize the four core purposes service environments fulfill.

Answered: 1 week ago