with out using scanner mul two matrices

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....

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();
   } 
  }
}









Related Tutorials/Questions & Answers:
with out using scanner mul two matrices
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
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
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
C Addition of two matrices
C Addition of two matrices In this section, we are going to calculate the sum of  two 2 X 2 matrices containing rows and columns. For this , we need... to input values for two matrices. To make the matrix of 2 X 2, we are using 
Write a C language program to read two matrices and multiply them?
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
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 handle Transaction IN and OUT in Inventory 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
Scanner
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
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 merge two word document using java   how to merge two word document using java
Multiplication of two polynomials using linked list in java
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
ModuleNotFoundError: No module named 'matrices'
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
Swap two numbers without using third variable
Swap two numbers without using third variable In this section we are going to swap two variables without using the third variable. For this, we have used input.nextInt() method of Scanner class for getting the integer type values
add tow numbers with out using arthamatic operaters
add tow numbers with out using arthamatic operaters  add tow numbers with out using arthamatic operaters
Read user input in Java using Scanner
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... the long value using Scanner class public float nextFloat
SQL Server row comparison using two tables
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
adding two numbers using bitwise operators
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
ModuleNotFoundError: No module named 'mul_table'
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'
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
days between two given dates using PHP
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
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
Swapping of two numbers in java
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.*
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
How to calculating time difference bewteen two countries using country name?
How to calculating time difference bewteen two countries using country name?  How to calculate the time difference between two countries. Example... bewteen two countries
matrices - Java Beginners
matrices  Write a program to add the two matrices  Hi Friend, Please visit the following link: http://www.roseindia.net/java/beginners/MatrixSum.shtml Hope that it will be helpful for you. Thanks
how to display duplicate elements with out using collection Frame work?
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?
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
Sum of two numbers using command line arguments in Java
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
can we use scanner class,class , object and methods to get output without using constructor ????
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
Java file scanner
Java file scanner In this section, you will learn how to read a file using Scanner class. Description of code: J2SE5.0 provides some additional classes.... It also parses the primitive data. Scanner class gives a great deal of power
How to make addition of two combobox values using jsp and javascript?
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
Java Matrix Addition Example
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:ADS_TO_REPLACE_1
Reading xml file using dom parser in java with out using getelementby tag name
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
Matrix addition in java
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
Java Matrix Multiplication Example
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
Scanner class
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
scanner program
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
Matrix multiplication 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
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  how to calculate addition of two distances in feets and inches using objects as functions arguments in java
How can we know the number of days between two given dates using PHP?
How can we know the number of days between two given dates using PHP?  How can we know the number of days between two given dates using PHP
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
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
Java Matrix Subtraction Example
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
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
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  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
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   
scanner - Java Beginners
scanner   how to ask user to enter index in arry using scanner
HOW TO FIND OUT GPS COORDINATES WITHOUT USING ONLINE DATABASE OR OTHERTHING ON MOBILE
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

Ads