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:
Getting Started with Custom Deserialization in Jackson
Hướng dẫn sử dụng luồng vào ra ký tự trong Java
HandlerAdapters in Spring MVC
Removing all Nulls from a List in Java
Merging Streams in Java
Setting the Java Version in Maven
How to Return 404 with Spring WebFlux
DynamoDB in a Spring Boot Application Using Spring Data
Hướng dẫn Java Design Pattern – Composite
How to Round a Number to N Decimal Places in Java
Redirect to Different Pages after Login with Spring Security
Java Concurrency Interview Questions and Answers
Java Program to Perform integer Partition for a Specific Case
Getting Started with GraphQL and Spring Boot
Java Program to Implement the Hill Cypher
Using a Custom Spring MVC’s Handler Interceptor to Manage Sessions
SOAP Web service: Upload và Download file sử dụng MTOM trong JAX-WS
Java Program to Implement Ford–Fulkerson Algorithm
Hướng dẫn sử dụng Lớp FilePermission trong java
Java Program to Implement DelayQueue API
Hướng dẫn sử dụng Java Reflection
New Features in Java 14
New Features in Java 13
Spring Cloud AWS – S3
Java Program to Find Strongly Connected Components in Graphs
Spring Boot - Service Components
Exploring the Spring Boot TestRestTemplate
Spring Security Login Page with React
RegEx for matching Date Pattern in Java
Hướng dẫn Java Design Pattern – Visitor
Convert String to Byte Array and Reverse in Java
Intersection of Two Lists in Java