(ComplexMatrix) Use the Complex class introduced in Programming Exercise 13.17 t
ID: 3683940 • Letter: #
Question
(ComplexMatrix) Use the Complex class introduced in Programming Exercise 13.17 to develop the ComplexMatrix class for performing matrix operations involving complex numbers. The ComplexMatrix class should extend the GenericMatrix class and implement the add, multiple, and zero methods. You need to modify GenericMatrix and replace every occurrence of Number by Object, because Complex is not a subtype of Number. Write a test program that creates the following two matrices and displays the result of addition and multiplication of the matrices by invoking the printResult method.
in java with output screen
Explanation / Answer
package Chapter_19; import ToolKit.Complex; import ToolKit.GenericMatrix; public class Exercise_11 { public static void main(String[] args) { Complex[][] m1 = createMatrix(3); Complex[][] m2 = createMatrix(3); ComplexMatrix matrix = new ComplexMatrix(); ComplexMatrix.printResult(m1, m2, matrix.addMatrix(m1, m2), '+'); } public static Complex[][] createMatrix(int size) { Complex[][] m1 = new Complex[size][size]; for (int i = 0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.