# a little help here at Multiplication table

Page 1 of 1

## 10 Replies - 2237 Views - Last Post: 19 July 2009 - 10:57 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=115065&amp;s=f28b6353c047b239aae631398e7cad90&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 NoobProgramer

Reputation: -5
• Posts: 191
• Joined: 15-June 09

# a little help here at Multiplication table

Posted 15 July 2009 - 10:49 PM

Here's my code

```public class MultiplicationTabs{

public static void main(String[]args)throws IOException {

int num  = 0;
System.out.print("Size of Multiplication Table: ");
System.out.println("Multiplication table of size: " +size);
for (int t = 0; t<= size; t++){
if( t==0)
System.out.print("\n");

}
for (int i = 1; i<=size; i++){

System.out.print("\n ");

for (int k = 1; k<=size; k++){
num = i*k;
System.out.print(" " + num);

}

}
}
}

```

my problem is how could i control the output of my multplication table

the output should be like this.
```Multiplication table of size: 5

1 2 3 4 5
1  1
2  2 4
3  3 6 9
4  4 8 12 16
5  5 10 15 20 25
Process completed.

```

diagonal lining.

This post has been edited by NoobProgramer: 15 July 2009 - 10:50 PM

Is This A Good Question/Topic? 0

## Replies To: a little help here at Multiplication table

### #2 NoobProgramer

Reputation: -5
• Posts: 191
• Joined: 15-June 09

## Re: a little help here at Multiplication table

Posted 16 July 2009 - 05:59 AM

BUMP.

### #3 NeoTifa

• Whorediot

Reputation: 3129
• Posts: 16,588
• Joined: 24-September 08

## Re: a little help here at Multiplication table

Posted 16 July 2009 - 07:06 AM

So what exactly are you trying to do? Hide all the numbers above the squares?

### #4 NoobProgramer

Reputation: -5
• Posts: 191
• Joined: 15-June 09

## Re: a little help here at Multiplication table

Posted 16 July 2009 - 06:53 PM

NeoTifa, on 16 Jul, 2009 - 06:06 AM, said:

So what exactly are you trying to do? Hide all the numbers above the squares?

Like at the example i gave for output

it will control the flow of the numbers diagonally
Like what you have seen at my sample output
```Multiplication table of size: 5

1  2  3  4  5
1  1
2  2  4
3  3  6  9
4  4  8  12  16
5  5  10  15  20  25

```

This post has been edited by NoobProgramer: 16 July 2009 - 06:54 PM

### #5 malerv

Reputation: 13
• Posts: 100
• Joined: 01-July 09

## Re: a little help here at Multiplication table

Posted 16 July 2009 - 07:10 PM

Hint, the second for should not go from 1 to size ...

### #6 NoobProgramer

Reputation: -5
• Posts: 191
• Joined: 15-June 09

## Re: a little help here at Multiplication table

Posted 16 July 2009 - 11:26 PM

my New Code

```import java.io.*;
public class MultiplicationTabs{

public static void main(String[]args)throws IOException {

int num  = 0;
System.out.print("Size of Multiplication Table: ");
System.out.println("Multiplication table of size: " +size);
for (int x= 1;x<= size; x++){
System.out.print(x+"  ");

}

for (int i = 1; i<=size; i++){

System.out.print("\n");

for (int k = 1; k<=size; k++){
num = i*k;
System.out.print(num+"  ");

}

}
}
}

```

the output was
```Size of Multiplication Table: 5
Multiplication table of size: 5
1  2  3  4  5
1  2  3  4  5
2  4  6  8  10
3  6  9  12  15
4  8  12  16  20
5  10  15  20  25
Process completed.

```

my problem is how can i add another 1-5 numbers at the
side of it and control or hide the other numbers
the ouput needed is kinda like this
```	1  2   3   4   5
1  1
2  2  4
3  3  6   9
4  4  8  12  16
5  5 10  15 20 25

```

This post has been edited by NoobProgramer: 16 July 2009 - 11:27 PM

### #7 Krysis09

Reputation: 1
• Posts: 14
• Joined: 25-April 09

## Re: a little help here at Multiplication table

Posted 16 July 2009 - 11:58 PM

```public class MultiplicationTabs
{

public static void main(String[]args)throws IOException
{

int num  = 0;
System.out.print("Size of Multiplication Table: ");
System.out.println("Multiplication table of size: " + size);

for(int i = 1; i < size+?; i++)
{
System.out.print("\t" + i);
}
System.out.println();
for (int i = 1; i < size+?; i++)
{
System.out.print(i + "\t");
for (int k = ?; k <= ?; k++)
{
num = i*k;
System.out.print(num + "\t");
}
System.out.println();
}
}
}
```

Should work the way you wanted... so long as you can fill in the "?'s".

P.s. None of the ?'s are == size.

### #8 NoobProgramer

Reputation: -5
• Posts: 191
• Joined: 15-June 09

## Re: a little help here at Multiplication table

Posted 17 July 2009 - 01:40 AM

```int num  = 0;
System.out.print("Size of Multiplication Table: ");
System.out.println("Multiplication table of size: " + size);

for(int i = 1; i < size+?; i++)
{
System.out.print(i + "\t");
}
System.out.println();
for (int i = 1; i <= size+?; i++)
{
System.out.print(i + "\t");
for (int k = 1; k <= i; k++)
{
num = k*i;
System.out.print(num + "\t");
}
System.out.println();
}
}
}

```

oh here's my edited new code
kindly check if its working
because im home now
i dont have jdk at home T_T

if it gets the output i needed.
this is it.
```  1 2 3 4 5
1 1
2 2 4
3 3  6  9
4 4  8  12 14
5 5 10 15 20 25

```

This post has been edited by NoobProgramer: 17 July 2009 - 02:04 AM

### #9 Krysis09

Reputation: 1
• Posts: 14
• Joined: 25-April 09

## Re: a little help here at Multiplication table

Posted 17 July 2009 - 08:28 AM

It's not quite what you're looking for... almost though. Your output (after I replaced the ?s with 1s:

```Size of Multiplication Table: 5
Multiplication table of size: 5
1   2   3   4   5
1   1
2   2   4
3   3   6   9
4   4   8   12  16
5   5   10  15  20  25
6   6   12  18  24  30  36

Process completed.
```

As you can see, one of the loops is going 1 too many times (size+1) and that you need to add a tab ("\t") before the first line reading: "1 2 3 4 5", so that your other numbers will line up correctly.

Hope that fixes it.

### #10 NoobKnight

Reputation: 49
• Posts: 238
• Joined: 14-July 09

## Re: a little help here at Multiplication table

Posted 17 July 2009 - 09:02 AM

Here's another solution with printf.

```	public static void main(String[] args) {
int Outer_loop=5;
int Inner_loop=0;

for(int i=1; i<Outer_loop+1; i++)
{
System.out.print(i + ": ");
for(Inner_loop=0; Inner_loop<i; Inner_loop++)
{
System.out.printf("%3d ", i*(Inner_loop+1));
}
System.out.println("");
}
}
```

```1:   1
2:   2   4
3:   3   6   9
4:   4   8  12  16
5:   5  10  15  20  25
```

Edited output...

This post has been edited by NoobKnight: 17 July 2009 - 09:10 AM

### #11 NoobProgramer

Reputation: -5
• Posts: 191
• Joined: 15-June 09

## Re: a little help here at Multiplication table

Posted 19 July 2009 - 10:57 PM

Thank you