Results 1 to 4 of 4
- 04-07-2009, 11:17 AM #1
[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; } }
- 04-07-2009, 11:57 AM #2
Member
- Join Date
- Apr 2009
- Posts
- 20
- Rep Power
- 0
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. :)
- 04-07-2009, 12:03 PM #3
Senior Member
- Join Date
- Dec 2008
- Location
- Hong Kong
- Posts
- 473
- Rep Power
- 5
i think is your console Screen Buffer Size problem...
.. your console may not display around 300 lines while a year has 365+ days
- 04-07-2009, 12:42 PM #4
Similar Threads
-
web programm (.jsp)
By renars1985 in forum New To JavaReplies: 1Last Post: 12-18-2007, 03:23 PM -
web programm (.jsp)
By renars1985 in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 12-18-2007, 08:34 AM -
Programm Error: cannot find symbol Help?
By junix in forum New To JavaReplies: 2Last Post: 12-10-2007, 05:30 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks