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 Boot Change Context Path
How to Store Duplicate Keys in a Map in Java?
Java Program to Implement Regular Falsi Algorithm
Java Program to Implement Segment Tree
Chuyển đổi Array sang ArrayList và ngược lại
Spring Boot Application as a Service
Java Program to Implement Gauss Jordan Elimination
Serialize Only Fields that meet a Custom Criteria with Jackson
Java Program to Implement the Hill Cypher
Java Program to Test Using DFS Whether a Directed Graph is Strongly Connected or Not
Java Program to Implement Naor-Reingold Pseudo Random Function
Jackson – Marshall String to JsonNode
Spring WebClient vs. RestTemplate
Java Program to Implement Suffix Tree
Show Hibernate/JPA SQL Statements from Spring Boot
Hướng dẫn Java Design Pattern – Composite
LinkedHashSet trong java
Generate Spring Boot REST Client with Swagger
RegEx for matching Date Pattern in Java
Spring 5 and Servlet 4 – The PushBuilder
Receive email using IMAP
Hướng dẫn Java Design Pattern – Mediator
Request a Delivery / Read Receipt in Javamail
Getting Started with GraphQL and Spring Boot
Validate email address exists or not by Java Code
Sử dụng JDBC API thực thi câu lệnh truy vấn dữ liệu
New in Spring Security OAuth2 – Verify Claims
Spring Cloud AWS – RDS
Guide to CountDownLatch in Java
Pagination and Sorting using Spring Data JPA
Java Program to Implement Miller Rabin Primality Test Algorithm
Java Program to Use the Bellman-Ford Algorithm to Find the Shortest Path