Results 1 to 20 of 21
Thread: how to do it with array !
 01122014, 09:31 AM #1Member
 Join Date
 Jan 2014
 Posts
 16
 Rep Power
 0
how to do it with array !
hello all programmers
i have this matrix by using 2 array dimension
2 2 2
3 3 3
4 4 4
i want to find sum of bottom Triangle like that
2
3 3
4 4 4
after that i want to find sum each of column like that
9 9 9
and i have another question sorry if my question is more but really i need that i want write a program by using array the output like that
2 2 2
3 3
4 4 4
please quick reply because i need it
thanks for all
 01122014, 09:40 AM #2
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,422
 Blog Entries
 7
 Rep Power
 28
Re: how to do it with array !
Let i be a row index number and let j be a column index number; for, say, the lower triangular matrix, the relation i >= j should hold. This observation is enough to construct two loops that iterate over the lower triangular matrix ... your other questions are a variation on the same theme and I guess you can manage now ...
And I'm sure you need this, but don't hurry us, because we don't need it and we've probably done this more than often. We are all volunteers here so you can't come here with a 'please quick reply'.
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
 01122014, 09:52 AM #3Member
 Join Date
 Jan 2014
 Posts
 16
 Rep Power
 0
Re: how to do it with array !
ok my friend @JosAH but toomorow i have examination in college i want to do it , and about volunteers yeah we are special thanks for all the members here , but can you do it practical ! and put all the code here !!
or if you give some topic like my question please give me
regards
 01122014, 10:31 AM #4
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,422
 Blog Entries
 7
 Rep Power
 28
Re: how to do it with array !
Build a wall around Donald Trump; I'll pay for it.
 01122014, 12:26 PM #5Member
 Join Date
 Jan 2014
 Posts
 16
 Rep Power
 0
Re: how to do it with array !
my friend i try it more than 10 count and this is my code
Java Code:import java.util.*; class twodimention { int x[][]=new int[3][3]; void input() { System.out.println("Please Enter number " ); Scanner s1=new Scanner (System.in); for (int i=0;i<3;i++) { for (int j=0;j<3;j++) { x[i][j]=s1.nextInt(); }}} void out() { for (int i=0;i<3;i++) { for (int j=0;j<3;j++) { System.out.print(x[i][j]); } System.out.println(); } System.out.println(""); } void sumrow () { int sum=0; int avg; for (int i=0;i<3;i++) { for (int j=0;j<3;j++) { sum=sum+x[i][j]; System.out.println("Sum of row = "+sum); }} System.out.println(""); } void sumcol () { int sum=0; int avg; for (int i=0;i<3;i++) { for (int j=0;j<3;j++) { sum=sum+x[j][i]; System.out.println("Sum if column = "+sum); }} System.out.println(""); } void min() { int min=x[0][0]; for (int i=0;i<3;i++) { for (int j=0;j<3;j++) { if (min>x[i][j]) { min=x[i][j]; }}} System.out.println("Minimize number is : " +min); System.out.println(""); } void minrow() { int min=x[0][0]; for (int j=0;j<3;j++) { if (min>x[0][j]) { min=x[0][j]; }} System.out.println("Minimize of row : " +min); System.out.println(""); } void mincol() { int min=x[0][0]; for (int i=0;i<3;i++) { if (min>x[i][0]){ min=x[i][0]; }} System.out.println("Minimiz of column : " +min); System.out.println(""); } void max() { int min=x[0][0]; for (int i=0;i<3;i++) { for (int j=0;j<3;j++) { if (min<x[i][j]) { min=x[i][j]; }}} System.out.println("Max number is : " +min); System.out.println(""); } void diagonal () { int i = 0, j = 0; int sum1 = 0, sum2 = 0; for (j = 0; j < x.length; j++) { for (i = 0; i < x.length; i++) System.out.print(x[j][i] + " "); System.out.println(); } for (j = 0; j < x.length; j++) { sum1 = sum1 + x[j][j]; } i = x.length  1; for (j = 0; j < x.length; j++) { if (i >= 0) { sum2 = sum2 + x[j][i]; i; } } System.out.println("Sum of Digonal :" + sum1 + " and " + sum2); System.out.println(""); } public static void main (String[]args) { twodimention op = new twodimention (); op.input(); op.out(); op.sumrow(); op.sumcol(); op.min(); op.max(); op.minrow(); op.mincol(); op.diagonal(); } }
regards
 01122014, 12:37 PM #6
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,422
 Blog Entries
 7
 Rep Power
 28
Re: how to do it with array !
This is not how this forum works; obviously your code doesn't do what you want it to do (otherwise you wouldn't be here); you can't just dump everything here, demand us to do it for you while you throw your hands up in the air. At least you could tell us what part of the code doesn't work and what you expect it to do ...
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
 01122014, 05:08 PM #7
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,422
 Blog Entries
 7
 Rep Power
 28
Re: how to do it with array !
@OP: I removed your other (identical) thread; stick to this thread and wait for an answer (if any); note that it is Sunday today and the forums are very quiet during the weekends; also read my previous reply again.
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
 01122014, 05:37 PM #8▼ dafuq did I do?
 Join Date
 Dec 2013
 Posts
 204
 Rep Power
 0
Re: how to do it with array !
For the triangle, you could go through the rows and print out a substring of the data in the columns, the length of the substring getting larger for every row. For the sum, you would go through each column and add all of the data in the rows, then print. This can be done with simple for loops.
EDIT: I have written a program with the following output:
Java Code:222 333 444 2 33 444 999 222 33 444
If that is what you needed I can gladly help you, you just need to put in the effortLast edited by zFollette; 01122014 at 05:53 PM.
 01122014, 05:55 PM #9Member
 Join Date
 Jan 2014
 Posts
 16
 Rep Power
 0
 01122014, 05:57 PM #10Member
 Join Date
 Jan 2014
 Posts
 16
 Rep Power
 0
 01122014, 06:04 PM #11▼ dafuq did I do?
 Join Date
 Dec 2013
 Posts
 204
 Rep Power
 0
 01122014, 06:05 PM #12Member
 Join Date
 Jan 2014
 Posts
 16
 Rep Power
 0
Re: how to do it with array !
it doesn't compile !!
Note : i use textpad editor for writing code .
 01122014, 06:08 PM #13▼ dafuq did I do?
 Join Date
 Dec 2013
 Posts
 204
 Rep Power
 0
 01122014, 06:11 PM #14Member
 Join Date
 Jan 2014
 Posts
 16
 Rep Power
 0
Re: how to do it with array !
just tell me this code what to do it for me nothing is change when i run my code !!!! please please do it for your self then put it here .
regards
 01122014, 06:16 PM #15Senior Member
 Join Date
 Jan 2013
 Posts
 168
 Rep Power
 8
Re: how to do it with array !
Here's how you can do it...
Java Code:public class Thing { public static void main(String[] agrs) { System.out.println("Nobody will do it for you."); } }
 01122014, 06:20 PM #16Member
 Join Date
 Jan 2014
 Posts
 16
 Rep Power
 0
 01122014, 06:21 PM #17Senior Member
 Join Date
 Jan 2013
 Posts
 168
 Rep Power
 8
 01122014, 06:25 PM #18▼ dafuq did I do?
 Join Date
 Dec 2013
 Posts
 204
 Rep Power
 0
 01122014, 06:37 PM #19Member
 Join Date
 Jan 2014
 Posts
 16
 Rep Power
 0
Re: how to do it with array !
hahah it doesn't matter the best thing for me like this
Java Code:System.out.println("Stay Here and not doing anything"); :D
 01122014, 06:56 PM #20Member
 Join Date
 Jan 2014
 Posts
 16
 Rep Power
 0
Similar Threads

Reading a text file into an Array and spliting the content into another Array
By jtothemax in forum New To JavaReplies: 15Last Post: 05142012, 12:42 PM 
Display Array on another class after extracting from txt file and into array problem
By jonathan920 in forum NetBeansReplies: 0Last Post: 05122011, 07:04 PM 
Variable of an object in an array compared to an element of another array?
By asmodean in forum New To JavaReplies: 23Last Post: 09072010, 08:12 PM 
Trying to make an array list // inserting an element to middle of array
By javanew in forum New To JavaReplies: 2Last Post: 09062010, 01:03 AM 
How to add an integer to a array element and the store that backinto an array.
By Hannguoi in forum New To JavaReplies: 1Last Post: 03312009, 06:40 AM
Bookmarks