Question: with out using scanner mul two matrices

Ads

 
 
 

Share on Google+Share on Google+

man
with out using scanner mul two matrices
1 Answer(s)      5 years 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....

Ads
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
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
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 
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
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 <
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
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 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
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
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
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
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
add tow numbers with out using arthamatic operaters
add tow numbers with out using arthamatic operaters  add tow numbers with out using arthamatic operaters
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
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
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
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
scanner - Java Beginners
scanner   how to ask user to enter index in arry using scanner
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
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
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
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
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
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
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.
Scanner vs. BufferedReader
Scanner vs. BufferedReader  I have to decide from these two classes to read a file. File is of .txt type and its size is around 4.5 GB. There other text files also which is around 7 to 10 GB. So, which class is to be used to read
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
Tutorials   
Java Spring Hibernate Struts Training What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java Java Example Codes and Tutorials in 2017 How do I read a large file quickly in Java? Is learning Java worthwhile? How to create first Java Program? Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly?

Ads

 
Advertisement null

Ads