# how to do it with array !

Show 40 post(s) from this thread on one page
Page 1 of 2 12 Last
• 01-12-2014, 10:31 AM
Dlovan
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
• 01-12-2014, 10:40 AM
JosAH
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,

Jos
• 01-12-2014, 10:52 AM
Dlovan
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
• 01-12-2014, 11:31 AM
JosAH
Re: how to do it with array !
Quote:

Originally Posted by Dlovan
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

So all you want to do is scrape 'teh internet for teh codez'; that is cheating and I (we) won't give it to you; we will help you though if you show some attempts yourself and got stuck; this forum is not a rent-a-coder forum.

kind regards,

Jos
• 01-12-2014, 01:26 PM
Dlovan
Re: how to do it with array !
my friend i try it more than 10 count and this is my code

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(); } }```
if you know all i want to do it , please do it for me

regards
• 01-12-2014, 01:37 PM
JosAH
Re: how to do it with array !
Quote:

Originally Posted by Dlovan
if you know all i want to do it , please do it for me

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,

Jos
• 01-12-2014, 06:08 PM
JosAH
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,

Jos
• 01-12-2014, 06:37 PM
zFollette
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:

Code:

```222 333 444 2 33 444 999 222 33 444```
Sorry for the code tags, it just looks better

If that is what you needed I can gladly help you, you just need to put in the effort
• 01-12-2014, 06:55 PM
Dlovan
Re: how to do it with array !
Quote:

Originally Posted by JosAH
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,

Jos

what !!!! if i know how to write code then if i mistake in the code i can correct my code , but tell me if i don't no how to write code and i haven't any idea how to write code !!!!!

i hope another one can help me
• 01-12-2014, 06:57 PM
Dlovan
Re: how to do it with array !
Quote:

Originally Posted by zFollette
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.

please don't tell me how do it , i put here my code if you know how do it please do it and put it here

regards
• 01-12-2014, 07:04 PM
zFollette
Re: how to do it with array !
Quote:

Originally Posted by Dlovan
please don't tell me how do it , i put here my code if you know how do it please do it and put it here

regards

Code:

```Toolkit t = Toolkit.getDefaultToolkit();                 for (int i = 0; i < 100; i++) {             t.beep();         }```
• 01-12-2014, 07:05 PM
Dlovan
Re: how to do it with array !
it doesn't compile !!

Note : i use textpad editor for writing code .
• 01-12-2014, 07:08 PM
zFollette
Re: how to do it with array !
Quote:

Originally Posted by Dlovan
it doesn't compile !!

Note : i use textpad editor for writing code .

Code:

`import java.awt.Toolkit;`
• 01-12-2014, 07:11 PM
Dlovan
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
• 01-12-2014, 07:16 PM
pj6444
Re: how to do it with array !
Here's how you can do it...

Code:

```public class Thing {     public static void main(String[] agrs) {         System.out.println("Nobody will do it for you.");     } }```
• 01-12-2014, 07:20 PM
Dlovan
Re: how to do it with array !
Quote:

Originally Posted by pj6444
Here's how you can do it...

Code:

```public class Thing {     public static void main(String[] agrs) {         System.out.println("Nobody will do it for you.");     } }```

yeah you write i try to it and found it best for me than your or other code

regards
• 01-12-2014, 07:21 PM
pj6444
Re: how to do it with array !
Quote:

Originally Posted by Dlovan
yeah you write i try to it and found it best for me than your or other code

regards

I don't really understand what you're saying?
• 01-12-2014, 07:25 PM
zFollette
Re: how to do it with array !
Quote:

Originally Posted by pj6444
I don't really understand what you're saying?

Did he completely miss the system beep loop I gave him?
• 01-12-2014, 07:37 PM
Dlovan
Re: how to do it with array !
hahah it doesn't matter the best thing for me like this
Code:

`System.out.println("Stay Here and not doing anything"); :D`
• 01-12-2014, 07:56 PM
Dlovan
Re: how to do it with array !
i try and found it look my friend for find triangle use this code

Code:

```         int i,j,c=0;                 for(i=0;i<3;i++)                 {                 for(j=0;j<3;j++)                 {                 if(i<=j)                 {                 c=c+x[i][j];                 }                 }                 }         System.out.println("The Sum of triangle  is:"+c);```
i hope all the members gain it :D:
Show 40 post(s) from this thread on one page
Page 1 of 2 12 Last