I need to design and implement an application that produces a multiplication table, showing the results of

import java.util.*;
import java.text.*;

public class MultTab7
{
    //----------------------------------------------------------------------------------------------
    //  Creates a multiplication table.
    //----------------------------------------------------------------------------------------------
    public static void main (String[] args)
    {
        int MAX = 12; 

        for (int r=1; r<=MAX; r++)
        {
            for (int c=1; c<= MAX; c++)
            {
                cout<<r*c;
            }
            cout <<'\n'
        }           
    }
}

multiplying the integers 1 through 12 by themselves.

Recommended Answers

All 8 Replies

The "cout <<'\n'" is not running well.

cout? why use a c++ standard output stream in a java program?
use System.out.println() instead

That's some variant of C,it's not Java

All the numbers are under eachother. I need it to be in a table format? Do I use the tab?

you need to learn java. cout is not java.

here's your code:

import java.util.Scanner;

public class multiplication_table {
    public static void main (String [] args){
        Scanner in = new Scanner (System.in);

        int max = 12;   

        for (int i = 1; i <= max; i++){
            for (int j = 1; j <= max; j++){
                System.out.print (i*j + "   ");
            }
        System.out.println ();
        }   

    }
}

@latecomer:
Your help, advice, and assistance are very welcome here. But please don't just post solutions to people's homework for them to copy & paste. All they learn from that is how to cheat. Give them guidance that allows them to learn how to do it for themselves.

I have my code already. I have the answers and everything. I just don't know how to put it in the format of a multiplication table.
MY CODE:

import java.util.*;
import java.text.*;

public class MultTab7
{
    //----------------------------------------------------------------------------------------------
    //  Creates a multiplication table.
    //----------------------------------------------------------------------------------------------
    public static void main (String[] args)
    {
        final int MAX = 12; 

        for (int row = 1; row <= MAX; row++)
        {
            for (int col = 1; col <= row; col++)
            {
                System.out.print (row*col + "\t");
            }
        }
    } 
}

The output is all of the results separated by the tab. But the results go straight across.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.