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 Compute the Volume of a Tetrahedron Using Determinants
Extra Login Fields with Spring Security
Spring Boot - Sending Email
Copy a List to Another List in Java
Using the Map.Entry Java Class
Java Web Services – Jersey JAX-RS – REST và sử dụng REST API testing tools với Postman
Java Program to Implement Fermat Factorization Algorithm
Intro to Spring Boot Starters
A Guide to EnumMap
Java Program to Construct a Random Graph by the Method of Random Edge Selection
Getting Started with GraphQL and Spring Boot
Java Program to Implement PrinterStateReasons API
Sử dụng JDBC API thực thi câu lệnh truy vấn dữ liệu
Java Program to Check Whether Graph is DAG
Running Spring Boot Applications With Minikube
Documenting a Spring REST API Using OpenAPI 3.0
Java Program to Create a Minimal Set of All Edges Whose Addition will Convert it to a Strongly Conne...
Spring Cloud Connectors and Heroku
Introduction to Netflix Archaius with Spring Cloud
Java Program to Generate Random Numbers Using Probability Distribution Function
Mảng (Array) trong Java
Java Program to Generate Random Partition out of a Given Set of Numbers or Characters
Java Program to Find MST (Minimum Spanning Tree) using Kruskal’s Algorithm
Java Program to Check whether Graph is a Bipartite using DFS
A Guide to HashSet in Java
Using JWT with Spring Security OAuth
Convert char to String in Java
Compact Strings in Java 9
Java Program to Implement Heap
Logging a Reactive Sequence
Form Validation with AngularJS and Spring MVC
Spring Boot - Runners