# Java, matrix

Suneeta
Java, matrix
4 Answer(s)      6 years and 9 months ago
Posted in : Java Beginners

java program to get output on the basis of users choice of switch statement perform operations addition, subtraction and multiplication of matrix.

October 28, 2012 at 3:06 PM

```import java.io.*;
class Matrix
{
int a ,b,i,j;
int matrix[][]=new int [12][14];
{
int a ,b,i,j;
int matrix[][]=new int [12][14];
DataInputStream is=new DataInputStream(System.in);
try
{
System.out.println("enter the row");
System.out.println("enter the col;umn");
System.out.println("enter the elements for the matrix");
for(i=0;i<a;i++)
{
for(j=0;j<b;j++)
{
}
}

System.out.println("the matrix that you entered is");

for(i=0;i<a;i++)
{
for(j=0;j<b;j++)
{
System.out.print(matrix[i][j]);
}
}
}
catch(Exception ex)
{}
}
public static void main(String args[])
{
Matrix m=new Matrix();
}
}
```

October 29, 2010 at 3:27 PM

Hello Friend,

Try this:

```import java.util.*;
class MatrixExamples{

public static void main(String[] args){
Scanner input = new Scanner(System.in);
int[][] A = new int[2][2];
int[][] B = new int[2][2];
int[][] C = new int[2][2];
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] = input.nextInt();
}
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] = input.nextInt();
}
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("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("2. Subtraction Of Matrix");
System.out.println("3. Multiplication Of Matrix");
System.out.println("4. Exit");
boolean quit = false;
do{
System.out.println();

case 1:
System.out.println("*Sum of 2 matrices*");
for(int i=0;i<2;i++){
for(int j=0;j<2;j++){
C[i][j]=A[i][j]+B[i][j];
System.out.print(C[i][j]+" ");
}
System.out.println();
}
break;
case 2:
System.out.println("Subtraction of 2 matrices*");
for(int i=0;i<2;i++){
for(int j=0;j<2;j++){
C[i][j]=A[i][j]-B[i][j];
System.out.print(C[i][j]+" ");
}
System.out.println();
}
break;
case 3:
System.out.println("*Multiplication of 2 matrices*");

for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
for(int k=0;k<2;k++)
{

C[i][j]+=A[i][k]*B[k][j];

}
}
}

for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
System.out.print(+C[i][j]+" ");
}
System.out.println();
}
break;
case 4:
quit = true;
break;
default:
System.out.println("Invalid Entry!");
}
}
while (!quit);
}
}
```

Thanks

October 28, 2012 at 3:06 PM

```import java.io.*;
class Matrix
{
int a ,b,i,j;
int matrix[][]=new int [12][14];
{
int a ,b,i,j;
int matrix[][]=new int [12][14];
DataInputStream is=new DataInputStream(System.in);
try
{
System.out.println("enter the row");
System.out.println("enter the col;umn");
System.out.println("enter the elements for the matrix");
for(i=0;i<a;i++)
{
for(j=0;j<b;j++)
{
}
}

System.out.println("the matrix that you entered is");

for(i=0;i<a;i++)
{
for(j=0;j<b;j++)
{
System.out.print(matrix[i][j]);
}
}
}
catch(Exception ex)
{}
}
public static void main(String args[])
{
Matrix m=new Matrix();
}
}
```

October 28, 2012 at 3:06 PM

```import java.io.*;
class Matrix
{
int a ,b,i,j;
int matrix[][]=new int [12][14];
{
int a ,b,i,j;
int matrix[][]=new int [12][14];
DataInputStream is=new DataInputStream(System.in);
try
{
System.out.println("enter the row");
System.out.println("enter the col;umn");
System.out.println("enter the elements for the matrix");
for(i=0;i<a;i++)
{
for(j=0;j<b;j++)
{
}
}

System.out.println("the matrix that you entered is");

for(i=0;i<a;i++)
{
for(j=0;j<b;j++)
{
System.out.print(matrix[i][j]);
}
}
}
catch(Exception ex)
{}
}
public static void main(String args[])
{
Matrix m=new Matrix();
}
}
```

Java, matrix
Java, matrix  java program to get output on the basis of users choice... of matrix.   Hello Friend, Try this: import java.util.*; class...]; int[][] C = new int[2][2]; System.out.println("Enter elements for matrix
Parallel multiplication matrix in java
Parallel multiplication matrix in java  hello dear I need parallel multiply matrix in java algorithm to account speed up and efficiency great wishes
matrix calculator - Java Beginners
matrix calculator  hi..... can you help me in writing source code of matrix calculator in java... i know you are the best you can do it!!! show yourself
matrix determination in java
matrix determination in java  hai
Matrix Addition using RMI in Java
Matrix Addition using RMI in Java  Source Code for Matrix Addition using RMI in Java
Matrix - Java Beginners
Matrix  give me the Matrix program   Hi friend, Code for Matrix Example in Java class MatrixExample{ public static void main...(" ]"); } System.out.println(); } } For more information on java visit to : http
code for multiplication of matrix in java using methods
code for multiplication of matrix in java using methods  code for multiplication of matrix in java using methods
how to create unit matrix in java of arbritary dimensions
how to create unit matrix in java of arbritary dimensions  i want to create the unit matrix of arbritary dimensions say (n*m).i m a new beginner to java.someone having the program for that? help would be appreciable
Matrix Multiplication in Java
Matrix Multiplication in Java In this Java tutorial we will demonstrate you 'Matrix Multiplication in Java' with the help of a simple example from which you can easily learn how to write a matrix multiplication program in Java
Java Transpose of a matrix
Java Transpose of a matrix In this section, you will learn how to determine the transpose of a matrix.The transpose of a matrix is formed by interchanging the rows and columns of a matrix such that row i of matrix becomes column i
Find sum of all the elements of matrix using Java
Find sum of all the elements of matrix using Java A matrix is a rectangular array of numbers. The numbers in the matrix are called its entries or its elements. A matrix with m rows and n columns is called m-by-n matrix or m × n matrix
Dividing of two Matrix in Java
Dividing of two Matrix in Java   ...;Here you will learn how to use two matrix array for developing Java program.  The java two dimensional array program is operate the two matrix. Now we
Matrix Example in Java
Matrix Example in Java       In Java tutorial, you will learn about array and matrix. An array... int data type. Matrix: A matrix is a collection of data in rows and columns format
how to make a matrix like datagrid in ide in java pls help
how to make a matrix like datagrid in ide in java pls help  how to make a datagrid mainly matrix in ajava standalone app
determinant of n*n matrix using java code
determinant of n*n matrix using java code  Here is my code... Scanner(System.in); System.out.println("enter dimension of matrix"); N...]; } System.out.println("enter the elements of matrix"); for(int i=0;i<N;i
Display tow dimensional array by matrix form using one for loop in java
Display tow dimensional array by matrix form using one for loop in java  Display tow dimensional array by matrix form using one for loop in java
Java create Identity matrix
Java create Identity matrix In this tutorial, you will learn how to create an identity or unit matrix. An identity matrix is a square matrix, of size n x n... elements are zeros. Here, we are going to create the unit matrix of arbitrary
want to display the follwing matrix format - Java Beginners
want to display the follwing matrix format  Hi frends, Actually i was working on the following matrix format........I neeed to use arraylist... gives 3 then he should get 3*3 matrix with folllowing data, and when user gives 4
finding the eigenvalues and eigenvector of n*n matrix in java
finding the eigenvalues and eigenvector of n*n matrix in java  Here...[][] {{4,3,1,2},{1,1,1,1},{1,2,1,1},{1,1,1,1} }; double t, c, s; int p, q, icount... = new double[2][2]; // makes V into a unit matrix V = new double[size][size
how to find the eigenvalue and eigenvector of n*n matrix in java
how to find the eigenvalue and eigenvector of n*n matrix in java  I m the new beginner in java and want to find eigenvalue and eigenvector of n*n matrix.where n is vary from n=4,5,6...... pls help me that would be appreciable
matrix substraction
matrix substraction  hai
matrix substraction
matrix substraction  hai
how to enter matrix data into a table of swings - Java Beginners
how to enter matrix data into a table of swings   Hi frends, I want to display a matrix data into a particular table...... Actually if the user input is 3*3 matrix and he got the matrix then it should create 3*3 table
transpose matrix
transpose matrix  write a program in java to declare a square... integers into the matrix and print the transpose of it. for this program u r given answer but if i entered 2 by 3 matrix it will not give answer ple check it once
Magic Matrix in GUI
Magic Matrix in GUI  I want program in java GUI contain magic matrix for numbers
transpose of matrix
transpose of matrix  write a program in java to declare a square matrices 'A' or order n which is less than 20.allow in user to input only positive integers into the matrix and print the transpose
column matrix
column matrix  columan wise total matrix
column matrix
column matrix  columan wise total matrix