# Multiplication Tables

Page 1 of 1

## 1 Replies - 2850 Views - Last Post: 05 December 2010 - 11:42 AMRate 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=203759&amp;s=0247d546cea8ca58f71b77e884c44900&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 lmr

Reputation: 0
• Posts: 6
• Joined: 05-December 10

# Multiplication Tables

Posted 05 December 2010 - 09:23 AM

My instructions are: Write a Java program that prints a multiplication table with M rows and N columns where M and N are entered by user (using the Scanner class). You need to do the following:
a). Declare two variables row and col for row and column numbers in the main( ) method.
. Define a static method called mTable(int row, int col) which takes row and col values from the main( ) method (you did this before).
c). In your main( ) method, display a prompt to ask user to enter row number and column number (between 0-9) and your program takes these two numbers and calls the method mTable by passing these two values into the method so that the mTable method will print the specified multiplication table.

This is my code:
```import java.util.*;
public class multiplicationtable {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
System.out.print("Enter number of rows using numbers 0-9: ");
int M = console.nextInt();

System.out.print("Enter number of columns using numbers 0-9:");
int N = console.nextInt();

mTable(M,N);
}

public static void mTable (int row, int col){
for (int i = 1; i <= row ; i++){
for (int j = 1; j <= col; j++){
System.out.print(i+ "x" +j+ "=" + i*j + "\t");
}
System.out.println();
}
}
}
```

Please tell me if you think I followed the instructions correctly, if my program works right, ect. Also if you have any ideas of what I could do differently or better, I am up for some constructive criticism.
Thanks =]

Is This A Good Question/Topic? 0

## Replies To: Multiplication Tables

### #2 pbl

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

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

## Re: Multiplication Tables

Posted 05 December 2010 - 11:42 AM

seems OK to me

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }