Use a two-dimensional, multi-dimensional array and pass it to a method and receive it back. You will create the array, add data, send it to a method to be updated and return it.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Use a two-dimensional, multi-dimensional array and pass it to a method and receive it back. You will
create the array, add data, send it to a method to be updated and return it.

public class MultiDimensionArray (
public static void main(String[] args) {
// Initialize 2-dimensional array
int[][] origTwoDimArr = {
(15, 25, 17, 24},
{6, 85, 12, 62),
(18, 22, 96, 5} };
// See the size of the array
System.out.println("Rows-
System.out.println("Columns
*+ origTwoDinArr.length);
using the
index-origTwoDimArr[0].length);
System.out.println("Columns using the 1 index - + origTwoDinArr[1].length "\n");
// Print out original content of array
System.out.println("Original contents of 2-dimensional array");
for (int a = 0; ac origTwoDimArr.length; a++)
{
}
for (int b = 0; b < origTwoDimArr[0].length; b++)
{
System.out.print(origTwoDimArr[a][b] + (b < 2?",":"")); // If last index, don't print comma
}
System.out.print("\n");
//newTwoDimArr
// Update the array
origTwoDinArr arrayMultiplier (origTwoDimArr); // Update the array
- arrayMultiplier(origTwoDimArr);
// Print out the updated content of the array
System.out.println("\nNew contents of 2-dimensional array");
for (int c = 0; c < origTwoDimArr.length; c++)
{
for (int d - 8; d < origTwoDimArr[0].length; d++)
{
}
System.out.print(origTwoDimArr[c][d] + (c < 2?",":""));
System.out.print("\n");
}
// This method will iterate through a two-dimensional array and
// update each cell by multiplying it by 10 and then returning it
private static int[][] arrayMultiplier (int[][] anArr)
{
System.out.println("\nInside the multiplier method");
// Create an array to match the one that was passed
int[][] tempArr- new int [anArr.length] [anArr [0].length];
// Use a nested loop to iterate through the array
for (int x = 0; x<anArr.length; x++)
for (int y = 0; y< anArr[0].length; y++)
{
tempArr[x][y] - anArr[x][y] 18;
System.out.println("Leaving the multiplier method");
return tempArn;
Transcribed Image Text:public class MultiDimensionArray ( public static void main(String[] args) { // Initialize 2-dimensional array int[][] origTwoDimArr = { (15, 25, 17, 24}, {6, 85, 12, 62), (18, 22, 96, 5} }; // See the size of the array System.out.println("Rows- System.out.println("Columns *+ origTwoDinArr.length); using the index-origTwoDimArr[0].length); System.out.println("Columns using the 1 index - + origTwoDinArr[1].length "\n"); // Print out original content of array System.out.println("Original contents of 2-dimensional array"); for (int a = 0; ac origTwoDimArr.length; a++) { } for (int b = 0; b < origTwoDimArr[0].length; b++) { System.out.print(origTwoDimArr[a][b] + (b < 2?",":"")); // If last index, don't print comma } System.out.print("\n"); //newTwoDimArr // Update the array origTwoDinArr arrayMultiplier (origTwoDimArr); // Update the array - arrayMultiplier(origTwoDimArr); // Print out the updated content of the array System.out.println("\nNew contents of 2-dimensional array"); for (int c = 0; c < origTwoDimArr.length; c++) { for (int d - 8; d < origTwoDimArr[0].length; d++) { } System.out.print(origTwoDimArr[c][d] + (c < 2?",":"")); System.out.print("\n"); } // This method will iterate through a two-dimensional array and // update each cell by multiplying it by 10 and then returning it private static int[][] arrayMultiplier (int[][] anArr) { System.out.println("\nInside the multiplier method"); // Create an array to match the one that was passed int[][] tempArr- new int [anArr.length] [anArr [0].length]; // Use a nested loop to iterate through the array for (int x = 0; x<anArr.length; x++) for (int y = 0; y< anArr[0].length; y++) { tempArr[x][y] - anArr[x][y] 18; System.out.println("Leaving the multiplier method"); return tempArn;
Expert Solution
steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Knowledge Booster
Math class and its different methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education