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:
Exploring the New Spring Cloud Gateway
Java InputStream to Byte Array and ByteBuffer
Reactive Flow with MongoDB, Kotlin, and Spring WebFlux
Java Deep Learning Essentials - Yusuke Sugomori
Java Program to Perform Partition of an Integer in All Possible Ways
Sort a HashMap in Java
Annotation trong Java 8
What is Thread-Safety and How to Achieve it?
Java Program to Implement Dijkstra’s Algorithm using Queue
Comparing Dates in Java
Composition, Aggregation, and Association in Java
Introduction to Spring Boot CLI
ETags for REST with Spring
Giới thiệu JDBC Connection Pool
Spring Boot - Bootstrapping
HashSet trong java
Xây dựng ứng dụng Client-Server với Socket trong Java
Spring WebClient and OAuth2 Support
Spring Data MongoDB Transactions
Java Program to Implement Warshall Algorithm
Receive email using POP3
Java Program to Implement Euler Circuit Problem
Jackson Unmarshalling JSON with Unknown Properties
Lấy ngày giờ hiện tại trong Java
Java Program to Implement Binomial Heap
Extra Login Fields with Spring Security
Java – File to Reader
Java Program to Implement LinkedTransferQueue API
Format ZonedDateTime to String
Hướng dẫn sử dụng luồng vào ra nhị phân trong Java
Java Program to Solve a Matching Problem for a Given Specific Case
Changing Annotation Parameters At Runtime