Question
Write a program called MatrixProcessor.java. In this program, your task is to read the file matrixA.txt, located at the website. Once you read the file,
Write a program called MatrixProcessor.java. In this program, your task is to read the file matrixA.txt, located at the website. Once you read the file, create and populate a two dimensional array with the information in the file. Notice that the first line of the file corresponds to the actual dimensions of the array (i.e., rows and columns), the rest of the lines in the file corresponds to the actual data that must be stored in the array. For each line in the file, it corresponds to a row in the matrix. Each row contains several columns separated by a blank space. The first line of the file corresponds to the information about the matrix. The 4 corresponds to the number of rows, the 3 corresponds to the number of columns. The next line: 13 9 68 corresponds to the first row, the 224 -1 1 to the second row, the 6 4 18 to the third, and 2 19 7 to the fourth row. Notice that the first line on the file is critical in order to create the matrix. Your program shall check if the dimensions represent positive numbers, i.e., greater than 0. In case the number of rows or columns are not positive values, your program shall throw a InvalidMatrixFormatException. You are responsible to create these exceptions. Test your program including the methods from Part II in order to get total points.
PART II: METHODS (60 PTS) Implement the following methods in MatrixProcessor.java every method shall have its own javadoc to get full credit. Test each of the methods with the matrix obtained from Part I.
1. getRowTotal: takes two arguments: a 2D array that contains ints, and an int r representing the row for the array, which it is desired to find the total of that row.
2. getColTotal: takes two arguments: a 2D array that contains ints, and an int c representing the col for the array, which it is desired to find the total of that column.
3. getSum: will take the 2D array of ints and will return the sum of all the indexes of the array.
4. getAVG: will take the 2D array of ints and will return the average of the array provided
5. getLargestRowVector: will take the 2D array of ints and will return a vector (a one-dimensional array) where each index represent the largest value per row. E.g., consider matrix A, the resulting vector after calling the method will be {68, 224, 18, 18}.
6. getLargestColVector: will take the 2D array of ints and will return a vector (a one-dimensional array) where each index represent the largest value per column. E.g., consider matrix A, the resulting vector after calling the method will be {224, 19, 68}. You can assume the given file will contain non-ragged array
matrixA.txt file
matrixA.txt 4 3 13 9 68 224 -11 6 4 18 2 19 7Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started