Write a program in java using two dimensional arrays. You should prompt the user to enter the number of rows and columns for your matrix. You should then prompt the user to enter values for each element of the matrix. Once the user has provided all the values for matrix, you should print the matrix and transpose of that matrix. A transpose of a matrix converts rows to columns and columns to rows. Example: Output: This program transposes a matrix. Output: Please enter the number of rows: User enters 2 Output: Please enter the number of columns: User enters 3 Enter value for row[0] column[0]: 9 Enter value for row[0] column[1]: 1 Enter value for row[0] column[2]: 2 Enter value for row[1] column[0]: 72 Enter value for row[1] column[1]: 3 Enter value for row[1] column[2]: 6 The matrix you entered is: 9 1 2 72 3 6 The transpose of this matrix has 3 rows and 2 columns and the transpose is: 9 72 1 3 2 6
Write a
enter the number of rows and columns for your matrix. You should then prompt the user
to enter values for each element of the matrix. Once the user has provided all the values for matrix, you should print the matrix and transpose of that matrix. A transpose of a matrix converts rows to columns and columns to rows.
Example:
Output: This program transposes a matrix.
Output: Please enter the number of rows:
User enters 2
Output: Please enter the number of columns:
User enters 3
Enter value for row[0] column[0]: 9
Enter value for row[0] column[1]: 1
Enter value for row[0] column[2]: 2
Enter value for row[1] column[0]: 72
Enter value for row[1] column[1]: 3
Enter value for row[1] column[2]: 6
The matrix you entered is:
9 1 2
72 3 6
The transpose of this matrix has 3 rows and 2 columns and the transpose is:
9 72
1 3
2 6
Trending now
This is a popular solution!
Step by step
Solved in 2 steps