Results 1 to 4 of 4
  1. #1
    latereg is offline Member
    Join Date
    Feb 2010
    Posts
    6
    Rep Power
    0

    Default Formatting output somewhat like a table

    How do you make your program display like this. with a variable number that gets updated in a loop

    Java Code:
    1 2 3 4
    5 6 7 8
    or

    Java Code:
    1 2 3 4
    5 6 7
    8 9
    10
    or like
    Java Code:
             Su Mo Tu We Th Fr Sa
                  1   2   3   4   5  6
             7   8   9   10 11 12 13
    while (num<=month)
    { 
      System.out.print(num)
    }
    and can you do this without a specific method?
    Last edited by Fubarable; 04-06-2010 at 02:08 AM. Reason: to be more specific

  2. #2
    latereg is offline Member
    Join Date
    Feb 2010
    Posts
    6
    Rep Power
    0

    Default

    it just moved my numbers out of format on the calender...sorry but i think you get what im saying

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  4. #4
    Join Date
    Apr 2010
    Location
    Aberystwyth
    Posts
    6
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    You could look into using System.out.printf("... ", ....)
    I am reasonably new to Java and didn't realize it had a printf. Thanks for the info :)

    @latereg

    You could use a counter

    Java Code:
    int days = 0;
    while (num<=month)
    { 
      System.out.print(num);
      days++;
      if(days==6){
         days=0;
         System.out.println();
      }
    }

Similar Threads

  1. Formatting this output to show "#.##"
    By twiggy62 in forum New To Java
    Replies: 9
    Last Post: 02-06-2010, 05:40 PM
  2. Replies: 1
    Last Post: 01-08-2010, 06:19 AM
  3. Need help formatting File Output
    By aaroncarpet in forum New To Java
    Replies: 2
    Last Post: 11-26-2009, 05:26 PM
  4. Need help formatting output and some code
    By A5i19 in forum New To Java
    Replies: 6
    Last Post: 11-09-2009, 04:58 AM
  5. Data formatting for the <display:table>
    By yuchuang in forum Web Frameworks
    Replies: 3
    Last Post: 12-14-2007, 10:52 AM

Posting Permissions

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