Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: rows and columns in the form of...

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    24
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default rows and columns in the form of...

    Hello, I am making rows and columns in the form of a multiplication table, listed below is my code:

    package assignments;
     
    public class MultTable 
    {
        public static void main (String [] args)
        {
     
            int row, column, x, y;
     
            for(row = 0; row < 8; row++)
            {
                System.out.println();
                for(column = 0; column < 15; column++)
                {
                    System.out.printf ("%3d", column*row);
     
                }//tier 2 for loop: columns
            }//tier 1 for loop: rows
     
            System.out.println ();
        }
    }

    If you see my sample run you can see that I have the multiplication table down but, I haven't completed it.

    I have to make the bottom left half of the whole table blank somehow

    for example, I have to make it halfway through the middle of the table the bottom left half full of white space...

    5 6 7 8 9
    12 14 16 18
    21 24 27
    32 36
    90

    hm, it's supposed to be the other way around horizontally.
    Last edited by ggx7; March 12th, 2014 at 10:35 AM. Reason: its actually supposed to be diagonally altered from top left to bottom right.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: rows and columns in the form of...

    And what have you tried? I assume you're trying to add spaces to format those numbers correctly (the forum eliminates extra white space). Have you tried doing something similar in your code?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Feb 2014
    Posts
    24
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default Re: rows and columns in the form of...

    Quote Originally Posted by KevinWorkman View Post
    And what have you tried? I assume you're trying to add spaces to format those numbers correctly (the forum eliminates extra white space). Have you tried doing something similar in your code?
    Hm.. I feel like I'm close but not quite there, I took a look at my notes and because I've written them poorly, they look like this

    for(column=n-row; column++), I think I'm getting closer to the idea.

    Need to write my notes better next time, here's my code listed below:
    package assignments;
     
    public class MultTable 
    {
        public static void main (String [] args)
        {
     
            int row, column, space, x, y;
            System.out.println ("         0   1   2   3   4   5   6   7   8   9"
                    + "   10   11   12   13   14   15");
            System.out.println ("________________________________________"
                    + "_______________________________________");
     
            for(row = 0; row <= 15; row++)
            {
     
                System.out.println();
     
                for(column = 0; column <= 15; column++)
                {
                    System.out.printf ("%5d", column*row);
     
                }//tier 2 for loop: columns
            }//tier 1 for loop: rows
     
            System.out.println ();
        }//end main
    }//end class

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: rows and columns in the form of...

    Put away your notes and play with the code you've posted. You can't possibly write notes on everything that you'll need to finish every project. Sometimes you have to examine the problem, think of possible solutions, and connect things you've learned in different ways to discover the right solution.

    Decide what needs to be fixed, consider the possible options to make the fix, and try them out. As you go through this phase of fix (maybe), test, fix, be sure to have code that you can always fall back on that's not too far off. Save the original version in a separate editor, make small changes one at a time, and save each version that gets closer to the desired result as you go. If you get completely lost and have scrambled code that doesn't compile or work at all, fallback to the last saved version.

  5. #5
    Junior Member
    Join Date
    Feb 2014
    Posts
    24
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default Re: rows and columns in the form of...

    Can anyone help me out? I've tried every possibly thing that I know of, I think I should at least have 3 for loops, played around with it, but still getting nowhere.

  6. #6
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: rows and columns in the form of...

    We're always interested in seeing "every possible thing you know of."

    First describe what you're trying to do - what's wrong with the output of the code you've posted. Then describe what you thought of to fix it and post the code you tried to implement what you thought of. What was wrong with those attempts? If you got errors from those attempts, post those. Start with the thought and code that got you closest to fixing the code.

Similar Threads

  1. Replies: 1
    Last Post: February 5th, 2014, 09:22 AM
  2. Replies: 4
    Last Post: February 22nd, 2013, 03:51 PM
  3. Building Table of Specified Rows and Columns
    By wale89 in forum Java Servlet
    Replies: 1
    Last Post: August 3rd, 2010, 08:57 AM
  4. Java Swing :Back Button from one form to another form
    By srinivasan_253642 in forum AWT / Java Swing
    Replies: 1
    Last Post: December 26th, 2009, 09:51 AM
  5. Need a loop for rows and columns
    By Ceasar in forum Loops & Control Statements
    Replies: 8
    Last Post: October 9th, 2009, 05:47 PM