Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MATERIAL COVERED Multidimensional arrays Notes: Make sure your TA has recorded your mark before leaving. The three exercises are independent - you can do them
MATERIAL COVERED Multidimensional arrays Notes: Make sure your TA has recorded your mark before leaving. The three exercises are independent - you can do them in any order. Only one of the three exercises is required. The Gold exercise is not much more difficult than the Silver exercise this time (some students may actually find it easier). BILONE a. A Random Array class 1. Download the file RandomArrayTemplate.java and save it as RandomArray.java before using it. The supplied TestLab4Bronze.java program will expect it to be named this way. 2. This class creates rectangular two-dimensional arrays filled with random positive integer values. Some of the class is written for you. Complete it by adding code in the four places marked //***ADD YOUR CODE HERE*** Add a private instance variable that will hold a 2-dimensional array of integers. b. Complete the constructor, which will create the 2-dimensional array, with the specified number of rows and columns, containing values from to range-1. The code to generate such random numbers is supplied in the comments. c. Complete the getRow method, which will return a copy (clone or deep copy) of the specified row of the array, as an array of integers of the correct length. In this method, use the built-in System.arraycopy method to copy the values from the original array into the result, as demonstrated in class. d. Complete the getCol method, which will return a copy (clone or deep copy) of the specified column of the array, as an array of integers of the correct length. In this method, you will have to copy the values yourself using a for loop since the System.arraycopy method cannot be used in this situation. 3. Run the supplied TestLab4Bronze.java program to test your class. Sample output from this program is shown below. User input is in blue. Your numbers will be different How many rows? 3 How many columns? 4 The rows contain: Row @: (15, 92, 48, 87] Row 1: [74, 32, 24, 10] Row 2: [55, 0, 50, 14] The columns contain: Column @: [15, 74, 55] Column 1: [92, 32, 0] Column 2: (48, 24, 50) Column 3: [87, 10, 14) r
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