Question: / * * * create a MathMatrix of the specified size with all cells set to the intialValue. * pre: numRows > 0 , numCols

/**
* create a MathMatrix of the specified size with all cells set to the intialValue.
* pre: numRows >0, numCols >0
* post: create a matrix with numRows rows and numCols columns.
* All elements of this matrix equal initialVal.
* In other words after this method has been called getVal(r,c)= initialVal
* for all valid r and c.
* @param numRows numRows >0
* @param numCols numCols >0
* @param initialVal all cells of this Matrix are set to initialVal
*/
public int[][] MathMatrix(int numRows, int numCols, int initialVal){
return null;
}
/**
* get the value of a cell in this MathMatrix.
* pre: row 0<= row < getNumRows(), col 0<= col < getNumColumns()
* @param row 0<= row < getNumRows()
* @param col 0<= col < getNumColumns()
* @return the value at the specified position
*/
public int getVal(int row, int col){
return 0;
}
/**
* Create and return a new Matrix that is a copy
* of this matrix, but with all values multiplied by a scale
* value.
* pre: none
* post: returns a new Matrix with all elements in this matrix
* multiplied by factor.
* In other words after this method has been called
* returned_matrix.getVal(r,c)= original_matrix.getVal(r, c)* factor
* for all valid r and c.
* @param factor the value to multiply every cell in this Matrix by.
* @return a MathMatrix that is a copy of this MathMatrix, but with all
* values in the result multiplied by factor.
*/
public MathMatrix getScaledMatrix(int factor){
return null;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!