Results 1 to 6 of 6
  1. #1
    ff123 is offline Member
    Join Date
    Apr 2009
    Posts
    14
    Rep Power
    0

    Default help with program

    hey my program is like user gives input to assign days in a month and from which day that month is started.. i have manages to print this
    XML Code:
    Sun  Mon  Tues  Wed  Thurs  Fri  Sat
    0     1     2     3     4    5   6
    
    from which day month is starting? = 4
    
              Sun  Mon  Tues  Wed  Thurs  Fri  Sat
                                     1     2     3    4
    5          6     7
    but what i need is

    XML Code:
              Sun  Mon  Tues  Wed  Thurs  Fri  Sat
                                    1     2     3      
               4     5    6     7
    any hint what should i do

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Use the Calendar constants to identify the days of the week rather than literal ints.

    Just a guess though.

    It might help to actually see your code.

  3. #3
    markw8500's Avatar
    markw8500 is offline Senior Member
    Join Date
    Jul 2008
    Location
    Pennsylvania, USA
    Posts
    136
    Rep Power
    0

    Default

    if you have everything doing what you need it to do except for your spacing issues, you can work them out by using the "\n" (newline) character...
    Who Cares... As Long As It Works...

  4. #4
    ff123 is offline Member
    Join Date
    Apr 2009
    Posts
    14
    Rep Power
    0

    Default

    Quote Originally Posted by masijade View Post
    Use the Calendar constants to identify the days of the week rather than literal ints.

    Just a guess though.

    It might help to actually see your code.
    Java Code:
       System.out.print("Enter number of days in a month ");
       daysinMonth = scan.nextInt();
       
       System.out.println("\t|Sun\t|Mon\t|Tues\t|Wed\t|Thurs\t|Fri\t|Sat");
       System.out.println("\t|0\t|1\t|2\t|3\t|4\t|5\t|6");
       
       System.out.print("Enter the first day of the month.");
       dayselect = scan.nextInt();
       System.out.println();
       
       System.out.println("\t|Sun\t|Mon\t|Tues\t|Wed\t|Thurs\t|Fri\t|Sat");
       
    
       
       for (int j=0;j<=dayselect;j++)
    			{
    				System.out.print("\t");
    			}	
       for(int i=1;i<=daysinMonth;i++)
    			{
    				System.out.print("|"+i+"\t")		
    			}

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    If you manually write out the result of:
    Java Code:
       for(int i=1;i<=daysinMonth;i++)
    			{
    				System.out.print("|"+i+"\t")		
    			}
    imagining you have 7 numbers to loop through, what do you get?

    Does it match up with the layout earlier for the days:
    Java Code:
       System.out.println("\t|Sun\t|Mon\t|Tues\t|Wed\t|Thurs\t|Fri\t|Sat");
    ?

    (The answer is no, by the way).

    Hope that helps.

  6. #6
    ff123 is offline Member
    Join Date
    Apr 2009
    Posts
    14
    Rep Power
    0

    Default

    I fixed it by using % operater but only 1st line is troubling.. any solution?

Similar Threads

  1. Execute A program from a Program!
    By Moncleared in forum Advanced Java
    Replies: 2
    Last Post: 02-22-2009, 05:17 PM
  2. Executing a program within a program
    By gibsonrocker800 in forum New To Java
    Replies: 5
    Last Post: 05-12-2008, 09:24 AM
  3. Replies: 0
    Last Post: 04-04-2008, 03:40 PM
  4. Replies: 0
    Last Post: 10-04-2007, 10:33 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
  •