write a java program to multiply two matrices and print there result. note: don't use the scanner and the values is passed at run time....

View Answers

August 8, 2011 at 11:26 AM

import java.io.*; class MatrixMultiplication{ public static void main(String[] args)throws Exception{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int[][] A = new int[3][3]; int[][] B = new int[3][3]; int[][] C = new int[3][3]; System.out.println("Enter elements for matrix A : "); for (int i=0 ; i < A.length ; i++) for (int j=0 ; j < A[i].length ; j++){ A[i][j] = Integer.parseInt(br.readLine()); } System.out.println("Enter elements for matrix B : "); for (int i=0 ; i < B.length ; i++) for (int j=0 ; j < B[i].length ; j++){ B[i][j] = Integer.parseInt(br.readLine()); } System.out.println("Matrix A: "); for (int i=0 ; i < A.length ; i++){ System.out.println(); for (int j=0 ; j < A[i].length ; j++){ System.out.print(A[i][j]+" "); } } System.out.println(); System.out.println(); System.out.println("Matrix B: "); for (int i=0 ; i < B.length ; i++){ System.out.println(); for (int j=0 ; j < B[i].length ; j++){ System.out.print(B[i][j]+" "); } } System.out.println(); System.out.println(); System.out.println("Result is: "); System.out.println(); for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ for(int k=0;k<3;k++){ C[i][j]+=A[i][k]*B[k][j]; } } } for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ System.out.print(+C[i][j]+" "); } System.out.println(); } } }

Ads

Related Tutorials/Questions & Answers:

with out using scanner mul two matrices write a java program to multiply two matrices and print there result. note: don't use the scanner and the values is passed at run time.... import java.io.*; class

input using scanner and add/sub/mul/div of a matrix hiiii...... performe matrix add/sub/mul/div using scanner

Advertisements

adding two numbers with out using any operator how to add two numbers with out using any operator import java.math.*; class AddNumbers { public static void main(String[] args) { BigInteger num1=new

Write a C language program to read two matrices and multiply them? Write a C language program to read two matrices and multiply them? Here is an example of multiplying two matrices using C language. #include <

How to find out the friend user between two columns in sql database Hi, Can any one please tell me ..how to find out the friend user between two columns in sql database? In other words i wanted to get the corresponding data from

How to merge two word document using java how to merge two word document using java

How to merge two word document using java how to merge two word document using java

How to handle Transaction IN and OUT in Inventory using java Hi... when the items are OUT, again same scan two times as we have two barcodes... are IN, we scan two times as we have two barcodes PartNo, SerialNo for each item

Multiplication of two polynomials using linked list in java I am doing a program "Multiplication of two polynomials using linked list in java...() { numC = 0; numE = 0; next = null; } // constructor with two argument public

SQL Server row comparison using two tables insertion process are completed in table1.string comparison using table2 to table1 if any changes in these tables and then upadated

add tow numbers with out using arthamatic operaters add tow numbers with out using arthamatic operaters

adding two numbers using bitwise operators adding two integer numbers with using bitwise opeators Hi Friend, Try the following code: public class AddNumberUsingBitwiseOperators { public static void main(String

days between two given dates using PHP How can we know the number of days between two given dates using PHP? Hi friends, Example: <html> <head> <title>Number of days between two

update database using two queries at a time String sql="insert into employee values(emp_seq.nextval,\'"+ename+"\',\'"+eadd+"\',\'"+ephone... can execute two queries with two different Statement object in the following way

ModuleNotFoundError: No module named 'matrices' Hi, My Python... 'matrices' How to remove the ModuleNotFoundError: No module named 'matrices... to install padas library. You can install matrices python with following

Scanner Hi, I am facing a problem in the following code as what... until i get the desired double value and come out of the loop once condition...= "Celsius"; do { Scanner temp_ip= new Scanner(System.in

Example of of reading user input in Java using Scanner In this section we... input is read using the scanner class. Information entered by user is printed... public long nextLong() For reading the long value using Scanner class

Swapping of two numbers in java In this example we are going to describe swapping of two numbers in java without using the third number in java. We have used input.nextInt() method of Scanner class for getting the integer type

Creating a File I/O using import scanner, io.* and text.* open a file for reading and open another file for writing data. input file hours-int, hourly rate-double, name-string. output file name-string, hours-int, hourly rate

ModuleNotFoundError: No module named 'mul_table' Hi, My Python... 'mul_table' How to remove the ModuleNotFoundError: No module named 'mul... have to install padas library. You can install mul_table python with following

ModuleNotFoundError: No module named 'mul_table' Hi, My Python... 'mul_table' How to remove the ModuleNotFoundError: No module named 'mul... have to install padas library. You can install mul_table python with following

Sum of two numbers using command line arguments in Java Hi, How to pass two values as parameter from command line and the get in it Java program? The calculate the sum of two numbers using command line arguments in Java

how to display duplicate elements with out using collection Frame work? how to display duplicate elements with out using collection Frame work

how to get data from list to map with out using a loop? List list...("15"); how to get this data into map with out using a loop. i want this data like this--map.put(name,id); Is it possible to do without using loop

addition of two combobox values using jsp and javascript How to make addition of two combobox values using jsp and javascript? <html> <h2>ComboBox</h2> <script language="javascript"> var arr

can we use scanner class,class , object and methods to get output without using constructor ???? im getting error here..i hav used scanner class... am i getting error here... can we get output using scanner class , object

Reading xml file using dom parser in java with out using getelementby tag name Hi, How to read the xml file using java with dom parser, but without using getelementbytag name, and also read the attribute values also. I had

the sum of two matrices of any order using the java language. In the given program... the sum of two matrices. You may have solved many Matrix Operations in Mathematics... array that stores the result of two matrices. Example: import java.util.

matrices. In java this is a simple program to adding two matrices, we have..., while adding two matrices the number of row and column of first matrix is equal...++ ) { c[i][j]= a[i][j]+b[i][j]; //Adding two matrices

to multiply two matrices. Like mathematical operations of two numbers, you can... the multiplication of two matrices of any order. In the given program, firstly we have... the multiplication of two matrices, we have performed following distinctive steps

how to calculate addition of two distances in feets and inches using objects as functions arguments how to calculate addition of two distances in feets and inches using objects as functions arguments in java

To find first two maximum numbers in an array,using single loop without sorting array. Java program to find first two maximum numbers in an array,using single loop without sorting array

To find first two maximum numbers in an array,using single loop without sorting array. Java program to find first two maximum numbers in an array,using single loop without sorting array

WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java

Q, 12 WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java Q, 12 WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java

WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java

WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java WAP to calculate addition of two distances in feets and inches using objects as functions arguments in java

multiplication of two matrices. In java this is a simple program to multiply two matrices... two-dimensional array. Here we are going to develop a Java code for matrices multiplication, while multiplying two matrices the number of column in first

the subtraction of two matrices. Not only, addition and multiplication, you can also subtract matrices. Here we are going to calculate the difference between two matrices of any order. In the given program, firstly we have allowed

Scanner class import java.util.*; class Dd { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int...; Here your code works fine..Which java version you are using? Actually

his profit..using scanner...scanner program a news paper boy purchase 100 papers every day.he purchases papers at Rs.1.50 and sells at Rs.2.00 at each.any unsold news papers

HOW TO FIND OUT GPS COORDINATES WITHOUT USING ONLINE DATABASE OR OTHERTHING ON MOBILE Hello Sir,, Good Morning Actually i have been assigned a task in my college to create a new mobile application and in that i've

HOW TO FIND OUT GPS COORDINATES WITHOUT USING ONLINE DATABASE OR OTHERTHING ON MOBILE Hello Sir,, Good Morning Actually i have been assigned a task in my college to create a new mobile application and in that i've

HOW TO FIND OUT GPS COORDINATES WITHOUT USING ONLINE DATABASE OR OTHERTHING ON MOBILE Hello Sir,, Good Morning Actually i have been assigned a task in my college to create a new mobile application and in that i've

program to display frequency count of each word in a file using Hashmap, Hashset and streamtokenizer.plz help me out .. import java.io.*; import java.util.*; class test1 { public static void main( String args[])throws

Swapping of two numbers without using third variable In this tutorial we will learn about swapping of two number in java without using third variable. This is simple program to swap two value using arithmetic operation Swapping of two

Scanner class what have to do when an error occur about Scanner class.i code scanner sc=new Scanner(System.in); but it shows an error regarding this. Use Scanner sc=new Scanner(System.in

Two Dimensional Array Program Using Nested For Loop ... of Java. In this lesson we will learn how to display arrange form of two...;. We are going to make a integer for array declaration Two dimensional array

of comparing two numbers and finding out the greater one. First of all, name a class "Comparing" and take two numbers in this class. Here we have taken a=24... Comparing Two Numbers

java code for print true if even and false if odd and print error if any float value with out using conditional and looping statement hi class Even{ public static void main(String[] arg){ int num=Integer.parseInt