# how do i build a 10*10 multiplier table(matrix)?

• 06-21-2010, 02:55 PM
Libertyman
how do i build a 10*10 multiplier table(matrix)?
i tried to create a code, but i am missing a few elements. i dont know what they are!

class Ex5
{
public static void main(String[] args)
{
int count;
count=0;
while(count<9)
{
System.out.println((count+1)*(count+1));

count=count+1;
}

}

}
• 06-21-2010, 03:11 PM
Norm
Quote:

i am missing a few elements. i dont know what they are
How can anyone help you if you don't know what is missing?
• 06-21-2010, 03:29 PM
Libertyman
how do you build a code that will calculate a 10 by 10 multiplication table. my code is incorrect.

i need someone who will help me

what do i do ?
• 06-21-2010, 03:34 PM
curmudgeon
I think that you need to step away from posting all your homework on the forum and start studying your notes and texts because from all your posts it appears that you don't have a clue -- not even enough to understand the help that has been given you. This may seem cold and harsh but no matter how much help you get here, without serious study you will fail your course. There is no substitute.
• 06-21-2010, 03:37 PM
Norm
First you need to define what the output is to look like, line by line.
Then write a line of code to print the first line.
Then look at what must be changed to print the next line.
Continue until done.
• 06-21-2010, 03:46 PM
Fubarable
hints:
1) Consider using nested for loops -- one inside of the other.
2) You can also use System.out.print(...) if you want to display something without creating a new line.

Much luck.
• 06-21-2010, 04:41 PM
Libertyman
Quote:

Originally Posted by Fubarable
hints:
1) Consider using nested for loops -- one inside of the other.
2) You can also use System.out.print(...) if you want to display something without creating a new line.

Much luck.

babes, it is my 3rd lesson. i have no books, all i have is the net. i cant do a while inside , a while, .. no one has taught me that.

• 06-21-2010, 04:44 PM
curmudgeon
Quote:

Originally Posted by Libertyman
babes, it is my 3rd lesson. i have no books, all i have is the net. i cant do a while inside , a while, .. no one has taught me that.

Most of us are self-taught, and no one is going to do this work for you, but fortunately, the net is more than enough. Please have a look at the Sun/Oracle Java tutorials: Learning the Java Language

Quote:

If all you want is the answer, then go to rent a coder . com.
• 06-21-2010, 06:49 PM
Libertyman
loop inside a loop doesnt work. i tried something like that

class Ex5
{
public static void main(String[] args)
{
int count;
count=0;
while(count<10)
{
System.out.println(count+1);
count=count+1;

int count1;
count1=0;
while(count<10)
{
System.out.println(count1+1);
count1=count1+1;
}
}

}

}
• 06-21-2010, 07:02 PM
Fubarable
1) Your inner loop is using the same loop variable, count rather than the new one, count1.
2) You're still using println where you should look into using print(..) as was suggeste above.
3) You really should read the tutorial on using for loops rather than while loops for this situation.

Also, when posting code here, please use code tags so that your code will retain its formatting and thus will be readable -- after all, your goal is to get as many people to read your post and understand your code as possible, right?

To do this, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.

Another way to do this is to manually place the tags into your code by placing the tag [cod&#101;] above your pasted code and the tag [/cod&#101;] below your pasted code like so:

Code:

```[cod&#101;]   // your code goes here   // notice how the top and bottom tags are different [/cod&#101;]```
Luck
• 06-21-2010, 07:35 PM
Libertyman
okay , i am done. the matrix works. no need for another loop....

class Ex5
{
public static void main(String[] args)
{
int count;
count=0;
while(count<10)
{
System.out.println((count+1)+" "+(count+1)*2+" "+(count+1)*3+" "+ (count+1)*4+" "+

(count+1)*5+" "+(count+1)*6+" "+(count+1)*7+" "+(count+1)*8+" "+(count+1)*9+" "+(count+1)*10);
count=count+1;
}

}

}
• 06-21-2010, 07:39 PM
curmudgeon
Quote:

Originally Posted by Libertyman
okay , i am done. the matrix works. no need for another loop....

OK, now see if you can change your code simply to create a 12 x 12 matrix. And what if you want to have the code so that the user can input how big he wants the matrix to be? If you use nested for loops, this type of change can be done simply and easily by just changing one number.

Bottom line: if you want to do this assignment well, you'll use nested loops as suggested above. If you don't care, then just hand what you have in.
• 06-21-2010, 07:44 PM
Libertyman
Quote:

Originally Posted by curmudgeon
OK, now see if you can change your code simply to create a 12 x 12 matrix. And what if you want to have the code so that the user can input how big he wants the matrix to be? If you use nested for loops, this type of change can be done simply and easily by just changing one number.

Bottom line: if you want to do this assignment well, you'll use nested loops as suggested above. If you don't care, then just hand what you have in.

it is my 3rd lesson. The teacher is not interested in short code..he is interested in an answer. we studied using one loop, and i didn with one loop