Menu

Friday, 20 November 2015

Matrix Class Demo (Java Concept)

 */
package matrix;

/**
 *
 * Adeniran Adetunji
 */
public class Matrix {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
       
        MatrixMath calMatrix = new MatrixMath();
       
               
        double[][]matrix_A = calMatrix.createMatrix();
        double[][]matrix_B = calMatrix.createMatrix();
       
        calMatrix.enterMatrixElement(matrix_A);
        calMatrix.enterMatrixElement(matrix_B);
       
        double [][]matrix_C= calMatrix.addMatrix(matrix_A, matrix_B);
       
        calMatrix.displayMatrix(matrix_A);
        System.out.println(" ");
        calMatrix.displayMatrix(matrix_B);
        System.out.println(" ");
        calMatrix.displayMatrix(matrix_C);
       
}


Output
run:
Enter Number of row(s)2
Enter Number of column(s)2
Enter Number of row(s)2
Enter Number of column(s)2
Enter element in row: 1 column :1==>3
Enter element in row: 1 column :2==>14
Enter element in row: 2 column :1==>2
Enter element in row: 2 column :2==>3
Enter element in row: 1 column :1==>56
Enter element in row: 1 column :2==>2
Enter element in row: 2 column :1==>3
Enter element in row: 2 column :2==>45
3.0       14.0    
2.0       3.0      

56.0      2.0      
3.0       45.0    

59.0      16.0    
5.0       48.0    

BUILD SUCCESSFUL (total time: 30 seconds)

No comments:

Post a Comment

Please drop your comment here, thanks.