Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

LANGUAGE: JAVA 1 public class ArrayPractice 2-{ public static void main(String[] args) int[][] array = {{5, 4, 2, 1, @}, {523, 63, 2342, 586, 1,

LANGUAGE: JAVAimage text in transcribedimage text in transcribed

1 public class ArrayPractice 2-{ public static void main(String[] args) int[][] array = {{5, 4, 2, 1, @}, {523, 63, 2342, 586, 1, 6534, @}, {10, 9, 2, @}}; //Call the fixArray method three times on this array: print(array); //Create a method to add the correct value to the array at the correct col, row public static void fixArray(int[][] arr, int row, int col, int value) //Do not make alterations to this method! public static void print(int[][] array) for(int[] row: array) for(int num: row) System.out.print(num + " "); System.out.println(); The last element in each array in a 2D array is incorrect. It's your job to fix each array so that the value 0 is changed to include the correct value. In the first array, the final value should be the length of the first array. In the second array, the final value should be the sum of the first value, and the second to last value in the array. In the third array, the final value should be the length of the 2D array. Create a method called fixArray(int[][] array, int row, int col, int value) that sets the [row][column] to the correct value. Then, call the fixArray method three times - once for each value change that you are supposed to make. When inputting values to fixArray, you will have to hard code the row value, but the column value and the new value should be set using the array accessor methods. For example, if we wanted to set the value of the first index in the first array to the length of the 2D array, we would write: fixArray(array, 0, 0, array.length)

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

Relational Database Design With Microcomputer Applications

Authors: Glenn A. Jackson

1st Edition

0137718411, 978-0137718412

More Books

Students also viewed these Databases questions