943,987 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 3224
  • Java RSS
Sep 16th, 2004
0

I need help with matrix....please!!!

Expand Post »
I got this far....but its not giving me the required output....can you give me some directions....here are my codes....thanks....please refer to my pdf file for the question.
//import java.lang.*;
import java.math.*;
import java.io.*;
class MatMulti extends Thread
{
static int in1[][];
static int in2[][];
static int out[][];
static int n=2;
int row;
MatMulti(int i)
{
row=i;
this.start();
}
public void run()
{
int i,j;
for(i=0;i<n;i++)
{
out[row]=0;
for(j=0;j<n;j++)
out[row]=out[row]+in1[row][j]*in2[j];
}
}
public static void main(String args[])
{
int i,j;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the order of Matrix A : ");
try
{
n=Integer.parseInt(br.readLine());
}catch(Exception e){}
in1=new int[n][n];
in2=new int[n][n];
out=new int[n][n];
System.out.println("Enter the First Matrix : ");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
try
{
in1[j]=Integer.parseInt(br.readLine());
}catch(Exception e){}
}
}
System.out.println("Enter the Second Matrix : ");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
try
{
in2[j]=Integer.parseInt(br.readLine());
}catch(Exception e){}
}
}
MatMulti mat[]=new MatMulti[n];
for(i=0;i<n;i++)
mat=new MatMulti(i);
try
{
for(i=0;i<n;i++)
mat.join();
}catch(Exception e){}
System.out.println("OUTPUT :");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
System.out.println(out[j]);
}
}
Attached Files
File Type: pdf assignment2.pdf (32.5 KB, 39 views)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rush88 is offline Offline
2 posts
since Sep 2004
Sep 17th, 2004
0

Re: I need help with matrix....please!!!

Tell us what it is you think you need to do with this code, and try to solve it yourself. you should just put the small snippet of code that shows how you would like to solve the problem, then we can help you.

Also, put your code within [ CODE ] [ / CODE ] tags. Otherwise it is hard to help you.


Ed
Reputation Points: 17
Solved Threads: 1
Junior Poster
cosi is offline Offline
153 posts
since Aug 2004
Sep 17th, 2004
0

Re: I need help with matrix....please!!!

Quote originally posted by cosi ...
Tell us what it is you think you need to do with this code, and try to solve it yourself. you should just put the small snippet of code that shows how you would like to solve the problem, then we can help you.

Also, put your code within [ CODE ] [ / CODE ] tags. Otherwise it is hard to help you.


Ed
hello ED!!
If you refer to my pdf file.....thats the out put i want
firstly the size of matrix...then input first matrix by user using dialog box and so on......but the output is displayed on command prompt
eg:
Matrix A:
1.0 2.0 3.0
4.0 5.0 6.0

Matrix B:
7.0 8.0 9.0
0.0 9.0 8.0
7.0 6.0 5.0

Product of Matrix A and B
28.0 44.0 40.0
70.0 113.0 106.0

thanks
Rashil
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rush88 is offline Offline
2 posts
since Sep 2004
Sep 18th, 2004
0

Re: I need help with matrix....please!!!

I don't want to solve your homework for you. Start thinking about how you will solve it and post your ideas/code snippets/pseudocode here. Then people will help you.


Ed
Reputation Points: 17
Solved Threads: 1
Junior Poster
cosi is offline Offline
153 posts
since Aug 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: creating dynamic textfields
Next Thread in Java Forum Timeline: jbuilder 9





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC