This is the java program to check the multiplication of the two matrices. Two matrices are multiplicable if and only if the number of rows of the left hand side matrix is equal to the number of columns of the right hand side matrix.
Here is the source code of the Java Program to Check Multiplicability of Two Matrices. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
//This is sample program to find out whether the two matrices are multiplicable or not //The complexity of the code is O(n)(linear) import java.util.Scanner; public class Multiplicability_Matrix { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter the dimension of the matrix:\n "); int rowA = sc.nextInt(); int colA = sc.nextInt(); System.out.println("Enter the dimension of the other matrix:\n "); int rowB = sc.nextInt(); int colB = sc.nextInt(); if(colA == rowB) { System.out.println("Matrices are multipilcable"); } else { System.out.println("Matrices are not multipilcable"); } sc.close(); } }
Output:
$ javac Muliplicability_Matrix.java $ java Muliplicability_Matrix Enter the dimension of the matrix: 1 2 Enter the dimension of the other matrix: 2 3 Matrices are multipilcable
Related posts:
Java Program to Find All Pairs Shortest Path
Java Program to Find Number of Spanning Trees in a Complete Bipartite Graph
Returning Image/Media Data with Spring MVC
Java Program to Find SSSP (Single Source Shortest Path) in DAG (Directed Acyclic Graphs)
Retrieve User Information in Spring Security
Guide to the Java Queue Interface
Java Program to Check whether Directed Graph is Connected using DFS
Exploring the Spring 5 WebFlux URL Matching
Phân biệt JVM, JRE, JDK
Spring Cloud Connectors and Heroku
The Difference Between map() and flatMap()
Loại bỏ các phần tử trùng trong một ArrayList như thế nào trong Java 8?
Java Program to Check Whether a Directed Graph Contains a Eulerian Cycle
Queue và PriorityQueue trong Java
Java Program to Implement Insertion Sort
Auditing with JPA, Hibernate, and Spring Data JPA
Guide to Mustache with Spring Boot
Lấy ngày giờ hiện tại trong Java
Java 8 Stream API Analogies in Kotlin
Java Program to Find Basis and Dimension of a Matrix
Java Program to Perform Finite State Automaton based Search
Java Program to Implement ArrayDeque API
Spring Security Form Login
Java – Reader to InputStream
Cơ chế Upcasting và Downcasting trong java
Adding Parameters to HttpClient Requests
Jackson Exceptions – Problems and Solutions
Java Program to Implement Kosaraju Algorithm
Java Program to Implement Nth Root Algorithm
Guide to @ConfigurationProperties in Spring Boot
Hướng dẫn sử dụng Printing Service trong Java
Java Program to Compute Cross Product of Two Vectors