You are to write a program that provides the user with a


You are to write a program that provides the user with a menu of choices that have to do with performing operations on two-dimensional arrays. In particular, the menu should provide the following options:

Addition of matrices
Scalar Multiplication
Multiplication of matrices
Determinant (only for 2 X 2 or 3 X 3 matrix)
Exit

The user should be allowed to request for multiple operations within a session. In other words, your main program should have a loop that calls a method menu until the user selects option 5. See below for more information on each of the options.

Option 1) You will need a method to prepare for the addition of matrices and to call a method to print the result. You should get the dimensions of the matrix from the user, print a message if the addition is undefined; otherwise get the matrices from the user, call a method add that takes the two matrices as input and returns the sum matrix, then call a method to print the resulting matrix.

Option 2) You will need a method to prepare for the scalar multiplication (e.g. each entry of the matrix is multiplied by an integer value.) and to call a method to print the result. You should get the dimensions of the matrix from the user and the integer value that will act as a scalar, call a method scalarMultiply that takes the matrix and integer value as input and returns a new matrix as the result. Then call a method to print the resulting matrix.

Option 3) You will need a method to prepare for the multiplication of matrices and to call a method to print the result. You should get the dimensions of the matrix from the user, print a message if the multiplication is undefined; otherwise get the matrices from the user, call a method multiply that takes the two matrices as input and returns the product matrix, then call a method to print the resulting matrix.

Option 4) You will need a method to prepare for calculating the determinant (the product of the entries on the main diagonal minus the product of the entries on the lesser diagonal). You should get the dimensions from the user. If the matrix is square, but not 2 X 2 or 3 X 3, you should inform the user that this program only calculates the determinant for 2 X 2 or 3 X 3 matrices. If the user enters the dimensions of a non-square matrix, then the message should be that determinants can only be calculated for square matrices. If the user enters the dimensions of either a 2 X 2 matrix or 3 X 3 matrix, read the matrix and call a method determinant that takes the matrix and the square size as parameters, and then prints a message with the result.

Notes:

Besides the 4 matrix operations, you will need methods to print the contents of a two-dimensional array and to read data, row by row, into a two dimensional array.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: You are to write a program that provides the user with a
Reference No:- TGS0661308

Expected delivery within 24 Hours