Results 1 to 5 of 5
  1. #1
    psx2514 is offline Member
    Join Date
    Oct 2012
    Posts
    50
    Rep Power
    0

    Question Please help with multiplication table.

    Java Code:
    public class Multiplication_table 
    {
    	public static void main(String[] args)
    	{
    		final int MAX_ROWS = 12;
    		final int MAX_COLUMNS = 12;
    		
    		System.out.print("\t");
    		for(int height = 1; height <= MAX_ROWS; height++)
    		{
    			for(int width = 1; width <= MAX_COLUMNS; width++)
    			{
    				System.out.print((width * height) + "\t");
    			}
    			System.out.println("");
    		}
    	
    		
    	}
    }
    Here is my output (I'm sure you see what the problem is).

    Java Code:
    	1	2	3	4	5	6	7	8	9	10	11	12	
    2	4	6	8	10	12	14	16	18	20	22	24	
    3	6	9	12	15	18	21	24	27	30	33	36	
    4	8	12	16	20	24	28	32	36	40	44	48	
    5	10	15	20	25	30	35	40	45	50	55	60	
    6	12	18	24	30	36	42	48	54	60	66	72	
    7	14	21	28	35	42	49	56	63	70	77	84	
    8	16	24	32	40	48	56	64	72	80	88	96	
    9	18	27	36	45	54	63	72	81	90	99	108	
    10	20	30	40	50	60	70	80	90	100	110	120	
    11	22	33	44	55	66	77	88	99	110	121	132	
    12	24	36	48	60	72	84	96	108	120	132	144
    How do I get it to be formatted like it is in this picture: http://www.vaughns-1-pagers.com/comp...able-25x25.gif
    Last edited by psx2514; 04-04-2013 at 04:44 AM.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,036
    Rep Power
    6

    Default Re: Please help with multiplication table.

    Check out either System.out.printf() or String.format().

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    psx2514 is offline Member
    Join Date
    Oct 2012
    Posts
    50
    Rep Power
    0

    Default Re: Please help with multiplication table.

    Quote Originally Posted by jim829 View Post
    Check out either System.out.printf() or String.format().

    Regards,
    Jim
    How does that help?

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,036
    Rep Power
    6

    Default Re: Please help with multiplication table.

    You edited your original post so I was replying to the lack of format.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  5. #5
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default Re: Please help with multiplication table.

    What is the very first thing that your code prints? Is that really needed?

Similar Threads

  1. Multiplication Table
    By BillyB in forum New To Java
    Replies: 17
    Last Post: 12-24-2010, 07:58 AM
  2. need help with this: multiplication table
    By MsIceCold in forum New To Java
    Replies: 7
    Last Post: 07-13-2010, 02:31 PM
  3. Multiplication Table
    By SwEeTAcTioN in forum New To Java
    Replies: 4
    Last Post: 02-24-2010, 05:11 AM
  4. Multiplication table
    By rjones215 in forum New To Java
    Replies: 3
    Last Post: 10-19-2009, 05:34 PM
  5. Help with multiplication table
    By Albert in forum New To Java
    Replies: 1
    Last Post: 07-10-2007, 05:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •