Create a method multiply(), that receives the 2D array you created in the program below as as an input, multiplies all of its elements and displays the product. Hint: your method won’t return anything import java.util.*; public class Two_D_Ragged { public static void Using_array_class(int R_array[][]) {System.out.println(""); System.out.println("using Arrays class Through the Ragged Array"); //Array.toString method is used to show array elements in R_array[0] System.out.println(Arrays.toString(R_array[0])); //Array.toString method is used to show array elements in R_array[1] System.out.println(Arrays.toString(R_array[1])); //Array.toString method is used to show array elements in R_array[2] System.out.println(Arrays.toString(R_array[2])); } //end of Using_array_class method public static void Using_for_each(int R_array[][]) { System.out.println("for-each-loop Through the Ragged Array"); int k = 0; //prints elements in R_array[0] for (int i:R_array[0]) { System.out.print(R_array[0][k] +" "); k++; } System.out.println(""); int l = 0; //prints elements in R_array[1] for (int i:R_array[1]) { System.out.print(R_array[1][l] +" "); l++; } System.out.println(""); int m = 0; //prints elements in R_array[2] for (int i:R_array[2]) { System.out.print(R_array[2][m] +" "); m++; } } //end of Using_for_each method public static void Using_for_loop(int R_array[][]) { System.out.println("for-loop Through the Ragged Array"); for (int i = 0; i < R_array.length; i++) { for (int j = 0; j < R_array[i].length; j++) { System.out.print(R_array[i][j]+ " "); } System.out.println(""); } } public static void main(String[] args) { int[][] R_array = new int [3][]; R_array[0] = new int[]{10, 20, 30}; R_array[1] = new int[]{40, 50}; R_array[2] = new int[]{60}; Using_for_loop(R_array);//calling method to print array elements using for loop Using_for_each(R_array); //calling method to print array elements using for-each loop Using_array_class(R_array); //calling method to print array elements using Array class }//end of main method }//end of Two_D_Ragged class

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter9: Advanced Modularization Techniques
Section: Chapter Questions
Problem 2GZ
icon
Related questions
Question

Create a method multiply(), that receives the 2D array you created in the program below as as an input, multiplies all of its elements and displays the product.

Hint: your method won’t return anything

import java.util.*;

public class Two_D_Ragged {

public static void Using_array_class(int R_array[][]) {

System.out.println("");

System.out.println("using Arrays class Through the Ragged Array");

//Array.toString method is used to show array elements in R_array[0]

System.out.println(Arrays.toString(R_array[0]));

//Array.toString method is used to show array elements in R_array[1]

System.out.println(Arrays.toString(R_array[1]));

//Array.toString method is used to show array elements in R_array[2]

System.out.println(Arrays.toString(R_array[2]));

} //end of Using_array_class method

public static void Using_for_each(int R_array[][]) {

System.out.println("for-each-loop Through the Ragged Array");

int k = 0;

//prints elements in R_array[0]

for (int i:R_array[0]) {

System.out.print(R_array[0][k] +" ");

k++;

}

System.out.println("");

int l = 0;

//prints elements in R_array[1]

for (int i:R_array[1]) {

System.out.print(R_array[1][l] +" ");

l++;

}

System.out.println("");

int m = 0;

//prints elements in R_array[2]

for (int i:R_array[2]) {

System.out.print(R_array[2][m] +" ");

m++;

}

} //end of Using_for_each method

public static void Using_for_loop(int R_array[][]) {

System.out.println("for-loop Through the Ragged Array");

for (int i = 0; i < R_array.length; i++) {

for (int j = 0; j < R_array[i].length; j++) {

System.out.print(R_array[i][j]+ " ");

}

System.out.println("");

}

}

public static void main(String[] args) {

int[][] R_array = new int [3][];

R_array[0] = new int[]{10, 20, 30};

R_array[1] = new int[]{40, 50};

R_array[2] = new int[]{60};

Using_for_loop(R_array);//calling method to print array elements using for loop

Using_for_each(R_array); //calling method to print array elements using for-each loop

Using_array_class(R_array); //calling method to print array elements using Array class

}//end of main method

}//end of Two_D_Ragged class

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Array
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,