Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A matrix is a two-dimensional array (it has both rows and columns). Instead of being just one row of length y , a matrix

image text in transcribedimage text in transcribed

A matrix is a two-dimensional array (it has both rows and columns). Instead of being just one row of length " y ", a matrix has " x " rows of length " y ". You declare a matrix with the following syntax: int[][]myMatrix=newint[rows][columns]; For this exercise, build a matrix out of input from Scanner. For example, for the input... 35434543543543 ...the first number on the first line gives you the number of rows (3), and the second number gives you the number of columns (4). The lines that follow are the matrix values. At the same time that you add values to your 2-D matrix, you should also add them to a 1-D ArrayList. Then, output the values as follows, by iterating through your ArrayList: 5,5,5,5,4,4,4,4,3,3,3,3, If the matrix (and ArrayList) are empty, print: "Empty!" Implementation hint: - Use a nested for loop to get input from the Scanner and fill your matrix. \begin{tabular}{l|l} AB & 5.19.1: LAB: Build a matrix \\ CTIVITY & 5. \end{tabular} 0/10 Matrix.java Load default template... 123456789101112131415imporimporpublipu} import java.util.Scanner; import java.util.Arraylist; public class Matrix \{ public static void main(String[] args) \{ Scanner scnr = new Scanner(System.in); /* Type your code here. Remember to call your 2-D array "myMatrix". */ Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box

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

More Books

Students also viewed these Databases questions

Question

Describe a traditional focus group.

Answered: 1 week ago

Question

Discuss the key people management challenges that Dorian faced.

Answered: 1 week ago

Question

How fast should bidder managers move into the target?

Answered: 1 week ago