Question: Need Help With Matrix Multiplication program in Java. ASAP ! Please show the work . Thanks! Goal to Write a Java program to read the
Need Help With Matrix Multiplication program in Java. ASAP ! Please show the work . Thanks!
Goal to Write a Java program to read the content from a input.txt file , multiply the matrix(2X2 or 3X3) in the file content and finally write the solution to a file.
Purpose: The goal in this assignment is to perform various matrix multiplications. Input matrices A and B are read from a file. Output matrices A*A, A*B, B*A and B*B are written to file. -Ask the user to enter the input and output file names. -Read the input data matrices A and B from the input file. (A sample input file is shown in Appendix A) -Read the number of rows n. -Read matrix A, which has n rows and n columns. -Read string A.(this data is not used) -Read matrix B, which has n rows and n columns. -Read string B. (this data is not used) - Calculate matrices AA, AB, BA and BB, where -AA=A*A -AB=A*B -BA=B*A -BB=B*B -Write the following to the output file (A sample output file is shown in Appendix B. Use type double for the matrix elements, and include one decimal place in the output of each number) -String First matrix A - line space -Matrix A, which has n rows and n columns (requires n lines) -line space -String Second matrix B - line space -Matrix B, which has n rows and n columns (requires n lines) -line space -String Matrix multiplication A*A - line space -Matrix AA, which has n rows and n columns (requires n lines) -line space -String Matrix multiplication A*B - line space -Matrix AB, which has n rows and n columns (requires n lines) -line space -String Matrix multiplication B*A - line space -Matrix BA, which has n rows and n columns (requires n lines) -line space -String Matrix multiplication B*B - line space -Matrix BB, which has n rows and n columns (requires n lines) -line space -Testing the code -Run the code using the provided file inputFileTest.txt (shown in Appendix A, and included in the Canvas file directory for Homework 3). The output should match the file outputFileTest.txt -Run the code using the provided file inputFile.txt. Include the output file as part of the files that you are submitting in the zipper folder.
Appendix A. Sample input file for 2x2 matrices. 2 1.0 2.0 3.0 4.0 A 3.0 4.0 1.0 2.0 B Appendix B. Sample output file for 2x2 matrices. First matrix A 1.0 2.0 3.0 4.0 Second matrix B 3.0 4.0 1.0 2.0 Matrix multiplication A*A 7.0 10.0 15.0 22.0 Matrix Multiplication A*B 5.0 8.0 13.0 20.0 Matrix Multiplication B*A 15.0 22.0 7.0 10.0 Matrix Multiplication B*B 13.0 20.0 5.0 8.0
Input.txt file content
5 1.0 2.0 1.0 3.0 4.0 3.0 1.0 2.0 5.0 1.0 2.0 4.0 3.0 6.0 1.0 4.0 1.0 2.0 3.0 2.0 1.0 2.0 1.0 3.0 1.0 A 4.0 2.0 3.0 1.0 2.0 1.0 3.0 1.0 2.0 3.0 4.0 5.0 2.0 3.0 4.0 3.0 1.0 7.0 5.0 2.0 1.0 2.0 3.0 4.0 1.0 B
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
