# create a multiplication table INVOKING

Page 1 of 1

## 2 Replies - 1012 Views - Last Post: 06 October 2013 - 04:58 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=330874&amp;s=dc9943ac5fa6766f043f300880bea768&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 michaelphongsak

• New D.I.C Head

Reputation: 0
• Posts: 1
• Joined: 06-October 13

# create a multiplication table INVOKING

Posted 06 October 2013 - 09:32 AM

I got most if this done and the program runs, but my professor said that I didn't complete it. I need to use a method which prints each row which is invoked from the method that printsthe overall multiplication table.

heres the assignment:
Multiplication Table
A set of nested for loops can be used to print a multiplication table using System.out.printf statements.

Write a program to print such a multiplication table, using a method to print each row, which is invoked from the method that prints the overall multiplication table.

my code:
```public class MultiplicationTable
{
public static void main (String[] args) {
// print header row
System.out.print(" ");
for (int i = 1; i <= 9; i++)
System.out.print(pad(i) + " ");
System.out.println();
// print separator
System.out.print(" ");
for (int i = 1; i <= 9; i++)
System.out.print(" ");
System.out.println();
// print main table
for (int i = 1; i <= 9; i++) {
System.out.print(pad(i) + " ");
for (int j = 1; j <= 9; j++) {
System.out.print(pad(i*j) + " ");
}
System.out.println();
}
} // end of main

// pad: add blanks to make it 3 long
public static String pad(int x) {
String s = new String();
if (x < 10) s = " " + x;
else if (x < 100) s = " " + x;
else s = "" + x;
return s;
}
}

```

Is This A Good Question/Topic? 0

## Replies To: create a multiplication table INVOKING

### #2 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 11447
• Posts: 43,143
• Joined: 27-December 08

## Re: create a multiplication table INVOKING

Posted 06 October 2013 - 03:27 PM

1) Please properly indent your code so that others, including you, can easily read it.

2) What have you tried? What specific problems or errors are you encountering?

### #3 pbl

• There is nothing you can't do with a JTable

Reputation: 8365
• Posts: 31,956
• Joined: 06-March 08

## Re: create a multiplication table INVOKING

Posted 06 October 2013 - 04:58 PM

Indent your code !