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:
Spring AMQP in Reactive Applications
Introduction to Using FreeMarker in Spring MVC
Introduction to Spring Data MongoDB
Create Java Applet to Simulate Any Sorting Technique
Java Program to Implement Sieve Of Eratosthenes
The XOR Operator in Java
Guide to Guava Table
Java Program to Implement Extended Euclid Algorithm
Java Program to Implement Bit Array
Comparing Long Values in Java
Returning Image/Media Data with Spring MVC
Quick Intro to Spring Cloud Configuration
Custom HTTP Header with the HttpClient
Loại bỏ các phần tử trùng trong một ArrayList như thế nào trong Java 8?
Java Program to Generate Random Hexadecimal Byte
Compare Two JSON Objects with Jackson
Weak References in Java
Tính kế thừa (Inheritance) trong java
Introduction to Netflix Archaius with Spring Cloud
Java Program to Implement Hash Tables with Double Hashing
Java Program to Find Maximum Element in an Array using Binary Search
Java Program to Implement JobStateReasons API
Hướng dẫn Java Design Pattern – Facade
Hướng dẫn sử dụng luồng vào ra ký tự trong Java
List Interface trong Java
Create a Custom Auto-Configuration with Spring Boot
Java Program to Compute DFT Coefficients Directly
Các kiểu dữ liệu trong java
Servlet 3 Async Support with Spring MVC and Spring Security
How to Delay Code Execution in Java
Spring Boot - Tomcat Port Number
Introduction to Java 8 Streams