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 anythingimport 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 methodpublic 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 methodpublic 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 loopUsing_for_each(R_array); //calling method to print array elements using for-each loopUsing_array_class(R_array); //calling method to print array elements using Array class}//end of main method}//end of Two_D_Ragged class

Question
Asked Oct 10, 2019

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

check_circleExpert Solution
Step 1
  • Create a public static type of method with a void return type and from the main method that method will be easily called without using the class object.
  • In multiply, method multipl...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour*

See Solution
*Response times may vary by subject and question
Tagged in

Engineering

Computer Science

Java

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: I am having issues with C++ because this code does not work: int main() {int userNum; userNum = 5;co...

A: Explanation:A proper C++ program should include header file “&lt;iostream&gt;”, begins with “#” sign...

question_answer

Q: What should an organization do to deter someone from violating policy or committing a crime? Discuss...

A: The nature of policy violation and crime committed by employees can be classified as-1)Accidental2)I...

question_answer

Q: Write two cin statements to get input values into birthMonth and birthYear. Then write a statement t...

A: Explanation:A C++ program should include header file “&lt;iostream&gt;”, begins with “#” sign.This h...

question_answer

Q: Use Java programming language Write a program that asks the user to enter 5 test grades (use an arra...

A: Note:Complete program is provided with all the required methods.Comments are provided for better und...

question_answer

Q: Create a new file (in Dev C++)  In Lab 2, you created a menu for a simple calculator program. In Lab...

A: Program AlgorithmDeclare the required variables and write a welcome message before starting the menu...

question_answer

Q: Please put into SOP formxz + (xy + ~z)

A: A Boolean expression is said to be in the Canonical form either it has purely min-terms or max-terms...

question_answer

Q: What form of storage doses a password manger store encrypted passwords? Is it local, web sites, clod...

A: Passwords managers allows one to generate strong and unique passwords and store them in one safe pla...

question_answer

Q: Write a program which does the following (name=xxx_Chapter81):1) Asks the user for the number of row...

A: Description:The following program is to print the two dimensional array.

question_answer

Q: In a file called RemoveVowels.java, write a program that: Asks the user to enter a word of text. Pr...

A:  First of all to import java.util.scanner object to use Scanner class. In java, you need to use the ...