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:
Cachable Static Assets with Spring MVC
@DynamicUpdate with Spring Data JPA
@Before vs @BeforeClass vs @BeforeEach vs @BeforeAll
Spring Boot Application as a Service
Creating a Web Application with Spring 5
Mệnh đề if-else trong java
Hướng dẫn sử dụng Printing Service trong Java
Spring’s RequestBody and ResponseBody Annotations
Java Program to Perform Finite State Automaton based Search
Different Ways to Capture Java Heap Dumps
Một số ký tự đặc biệt trong Java
A Quick Guide to Spring MVC Matrix Variables
Java Program to Generate All Subsets of a Given Set in the Gray Code Order
Spring Cloud AWS – EC2
Overview of the java.util.concurrent
Java Program to Construct an Expression Tree for an Postfix Expression
Java Program to Implement Merge Sort Algorithm on Linked List
Java – InputStream to Reader
Hướng dẫn Java Design Pattern – Object Pool
Apache Commons Collections MapUtils
Spring Cloud – Bootstrapping
Java Program to Implement Sorted List
Spring RequestMapping
Jackson – Marshall String to JsonNode
HttpClient Connection Management
Spring Security – Reset Your Password
Spring’s RequestBody and ResponseBody Annotations
Java equals() and hashCode() Contracts
OAuth2 for a Spring REST API – Handle the Refresh Token in Angular
Create a Custom Auto-Configuration with Spring Boot
Logging a Reactive Sequence
DistinctBy in the Java Stream API