Home Answers Viewqa Java-Beginners with out using scanner mul two matrices

 
 


man
with out using scanner mul two matrices
1 Answer(s)      a year and 9 months ago
Posted in : Java Beginners

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 Pages:
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
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 <
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
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
without scanner
attributes : name , age , salary and note that we need to solve it using array and class and didn't use the scanner .   Hi Friend, Whether
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
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: import java.util.
Pattern,Matcher,Formatter and Scanner classes
using the Formatter and Scanner classes and the PrintWriter.format/printf... primitive types and strings using regular expressions. A Scanner breaks its... its source. A Scanner converts the input from its source into tokens using
scanner - Java Beginners
scanner   how to ask user to enter index in arry using scanner
scanner problem - Java Beginners
scanner problem  the program that enters sides of the triangle using scanner and outputs the area of triangle  Hi Friend, We... main(String []args){ Scanner scanner = new Scanner(System.in
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
Hp scanner - Java Beginners
Hp scanner  Hi guys, i would like to access hp scanner using java programme. could you refer me some useful information to proceed
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
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
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
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
In and Out parameters - SQL
In and Out parameters  What are in and out parameters in stored... no's and get output using parameters in MySql  Hi Friend, Stored Procedures... parameters-IN,OUT,INOUT. 1)IN: It is default parameter which is passed
XII STD RECURSION WITHOUT SCANNER
for two input numbers. the code of my program is as follows and the error comes... not wish to use the scanner class Is there anything i can do to improve...( System.in)); System.out.println("Input two nos"); int
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
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
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
JSP implicit object out
;    out.clearBuffer(); (6)flush : Two methods of out...JSP implicit object out In this Section, we will discuss about implicit object out & it's methods. Out object denotes the Output stream
Is there anyone out there?
Is there anyone out there?  Hi please could somebody respond as I am seeking advice but not getting any and do not know whether or not to continue using this site
'append' & 'fade out/in' on mouse hover
of the list : When we hover on last two elements ., it will fade in/out + append...'append' & 'fade out/in' on mouse hover In this tutorial, we will discuss about how to apply 'append' & 'fade out/in'
Write a java program that prints out the following menu???
Write a java program that prints out the following menu???  Write a java program that prints out the following menu. Auser can interact with the menu using numbers (1,2,3,4,5,6). The menu will be printed again if the user enters
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
<c: out> in JSTL
. It is a must attribute in the tag. We are just calculating the multiplication of two numbers by using the <c: out> core action tag. The code of the example... Calculation by using c: out</title> </head> <body bgcolor
Multiplication of Two Number in Class
Multiplication of Two Number in Class  ... multiply two number. A class consists of a collection of types of encapsulation... that can used to create object of  the class. The class define two public
<c: out> attribute escapeXml
tag <c: set> with a body. We are using this tag to differentiate between...; core action tag. We have used two attributes of <c: out>. The attribute..."> We are going to use the attribute escapeXml of c:out to show
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
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
add tow numbers with out using arthamatic operaters
add tow numbers with out using arthamatic operaters  add tow numbers with out using arthamatic operaters
Two Indexes in For Loop
use two indexes in a for loop. We can solve this problem by using for loop...Two Indexes in For Loop     ... two index of type int inside a for loop, the indexes are FIndex and otherIndex
Out Of Memory Exception Erorr
Out Of Memory Exception Erorr  hello how are you?I hope you are fine I'm using jgrasp program my problem is in java programming my program compiled with no problem but when I run it this exception appears: Exception
Sum of two Matrix
Sum of  two Matrix       In this section, we are going to calculate the sum of two matrix... to this. In this program we are going to calculate the sum of two matrix. To make this program
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
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
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
Using Flex Containers
Using Flex Containers       Flex delivers containers of two types one is for laying out the components and other is for navigating from one child container to the other. Here
Console Input: Scanner
, closing it would be important. Example using Scanner in a loop 1 2.../ScannerLoop.java // Purpose: Read from the console in a loop using Scanner. // Author... Java NotesConsole Input: Scanner The java.util.Scanner class (added
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
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
Fading elements in and out example
Fading elements in and out example       Fading elements in and out example..., a list is given , if we hover on first two element, "<<<"
JavaScript Zoom in and Zoom out
illustrates you how to zoom in and zoom out of an image using JavaScript. Here we... and width of the image and make it to show the effect Zoom In and Zoom Out. The function stopZoom() provides the functionality to stop the image effect by using
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.