1 Replies - 3382 Views - Last Post: 05 December 2010 - 11:42 AM Rate Topic: -----

#1 lmr   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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.
B). 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();
    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");

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   User is offline

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

Reputation: 8378
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Multiplication Tables

Posted 05 December 2010 - 11:42 AM

seems OK to me
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1