Results 1 to 4 of 4
  1. #1
    AlejandroPe's Avatar
    AlejandroPe is offline Member
    Join Date
    Mar 2009
    Posts
    37
    Rep Power
    0

    Question [SOLVED] my programm doesn´t run like it shoud be.

    :confused:
    Hello!
    I can't find the problem with this code. It's supposed to print all the dates from 1 / 1 /2000 to 12 / 31 / 2000, year can be entered as argument. It always starts 3 / 9 / 2000 :mad: instead of starting 1 / 1 / 2000

    Java Code:
    class DayCounterII{
    	public static void main(String[] arguments){
    		int year = 2000;
    		if(arguments.length > 0)
    			year = Integer.parseInt(arguments[0]);
    		System.out.println(year + " has these dates:\n");
    		for (int month = 1; month < 13; month++)
    		    for (int days = 1; days <= countDays(month, year); days++)
    			     System.out.println(month + "/" + days + "/" + year);
    			     
    			
    	}
    
    static int countDays(int month, int year) {
    	int count=0;
    	switch (month) {
    		case 1:
    		case 3:
    		case 5:
    		case 7:
    		case 8:
    		case 10:
    		case 12:
    			count = 31;
    			break;
    		case 4:
    		case 6:
    		case 9:
    		case 11:
    			count = 30;
    			break;
    		case 2:
    			if (year%4 == 0)
    				count = 29;
    			else
    				count = 28;
    			if ((year%100 == 0) & (year%400 != 0))
    				count = 28;
    		}
    		return count;
    	} 
    }

  2. #2
    kbindumadhavi is offline Member
    Join Date
    Apr 2009
    Posts
    20
    Rep Power
    0

    Default

    Your program meets the requirement.

    This seems to be the problem with the size of your window. Because of that you are not able to see the whole result which is being printed.

    Can you tell me which editor you are using to execute this program?

    If you are running this program with command prompt, please changescreen buffer height to 9999 and check this. You can see your whole result. :)

  3. #3
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    6

    Default

    i think is your console Screen Buffer Size problem...
    .. your console may not display around 300 lines while a year has 365+ days

  4. #4
    AlejandroPe's Avatar
    AlejandroPe is offline Member
    Join Date
    Mar 2009
    Posts
    37
    Rep Power
    0

    Default

    Perfect!! I changed screen buffer size to 400 !!:eek: and it works of course!

Similar Threads

  1. web programm (.jsp)
    By renars1985 in forum New To Java
    Replies: 1
    Last Post: 12-18-2007, 03:23 PM
  2. web programm (.jsp)
    By renars1985 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 12-18-2007, 08:34 AM
  3. Programm Error: cannot find symbol Help?
    By junix in forum New To Java
    Replies: 2
    Last Post: 12-10-2007, 05:30 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
  •