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:
Send an email with an attachment
Java Program to Implement the Monoalphabetic Cypher
Toán tử instanceof trong java
The Basics of Java Security
Java Program to Implement SimpeBindings API
Java Program to Perform Insertion in a 2 Dimension K-D Tree
Java Program to Implement RoleUnresolvedList API
Create a Custom Auto-Configuration with Spring Boot
Java Program to Test Using DFS Whether a Directed Graph is Strongly Connected or Not
Spring Boot - Zuul Proxy Server and Routing
Java Program to Implement Traveling Salesman Problem using Nearest neighbour Algorithm
Get the workstation name or IP
OAuth2 for a Spring REST API – Handle the Refresh Token in Angular
Java Program to Solve Travelling Salesman Problem for Unweighted Graph
Jackson Annotation Examples
Biểu thức Lambda trong Java 8 – Lambda Expressions
Most commonly used String methods in Java
Tránh lỗi ConcurrentModificationException trong Java như thế nào?
Java – String to Reader
Guide to the Java ArrayList
Java Program to Emulate N Dice Roller
Java Program to Solve a Matching Problem for a Given Specific Case
Spring WebClient and OAuth2 Support
Understanding Memory Leaks in Java
Java Program to Implement Repeated Squaring Algorithm
Comparing Dates in Java
Java Program to Implement HashSet API
Introduction to Project Reactor Bus
Java Program to Implement Graph Coloring Algorithm
Spring Security Custom AuthenticationFailureHandler
Build a REST API with Spring and Java Config
Hướng dẫn Java Design Pattern – Template Method