Java Objective: Design and implement simple matrix manipulation techniques. Details: Your java program should use 2D arrays to implement simple matrix operations. Your program should do the following: • Read the number of rows and columns of a matrix M1 from the user. Use an input validation  loop to make sure the values are greater than 0.  • Read the elements of M1 in row major order • Print M1 to the console; make sure you format as a matirx • Repeat the previous steps for a second matrix M2 • Create a matrix M3 that is the transpose of M1 and print it to the console • Check if M1 and M2 can be added (should have the same dimensions). If possible, add M1  and M2 and print the result to the console. Otherwise print an error message. • Multiply M1 and M2 if possible and print to the console. If the matrices cannot  be multiplied, print an error message.  Implementation requirements: • Use a helper method for reading a positive integer using an input validation loop. • Use a helper method for printing a matrix.  Your helper methods should be private and static, and called in the main method. Example run: Enter number of rows for M1 -2 Invalid value 2 Enter number of columns for M1 3 Enter elements for M1, in row major order 1 2 3 4 5 6 M1: 1 2 3 4 5 6 Enter number of rows for M2 2 Enter number of columns for M2 3 2 Enter elements for M1, in row major order 4 5 6 7 8 9 M2: 4 5 6 7 8 9 M3 (transpose of M1): 1 4 2 5 3 6 M1 + M2: 5 7 9 11 13 15 Formatting Requirements • Follow indentation rules • Use descriptive variable names • Comment your code

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

Java Objective:
Design and implement simple matrix manipulation techniques.
Details:
Your java program should use 2D arrays to implement simple matrix operations.
Your program should do the following:
• Read the number of rows and columns of a matrix M1 from the user. Use an input validation 
loop to make sure the values are greater than 0. 
• Read the elements of M1 in row major order
• Print M1 to the console; make sure you format as a matirx
• Repeat the previous steps for a second matrix M2
• Create a matrix M3 that is the transpose of M1 and print it to the console
• Check if M1 and M2 can be added (should have the same dimensions). If possible, add M1 
and M2 and print the result to the console. Otherwise print an error message.
• Multiply M1 and M2 if possible and print to the console. If the matrices cannot 
be multiplied, print an error message. 
Implementation requirements:
• Use a helper method for reading a positive integer using an input validation loop.
• Use a helper method for printing a matrix. 
Your helper methods should be private and static, and called in the main method.
Example run:
Enter number of rows for M1
-2
Invalid value
2
Enter number of columns for M1
3
Enter elements for M1, in row major order
1 2 3 4 5 6
M1:
1 2 3
4 5 6
Enter number of rows for M2
2
Enter number of columns for M2
3
2
Enter elements for M1, in row major order
4 5 6 7 8 9
M2:
4 5 6
7 8 9
M3 (transpose of M1):
1 4
2 5
3 6
M1 + M2:
5 7 9
11 13 15
Formatting Requirements
• Follow indentation rules
• Use descriptive variable names
• Comment your code

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

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
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