Results 21 to 22 of 22
Thread: annualCalendar Java Program
- 04-07-2011, 03:30 PM #21Senior Member
- Join Date
- Jun 2008
- Rep Power
I think the forum members are frustrated because your misunderstanding isn't a Java issue, but simple logic. It's easy to get confused trying to write code without having first figured out the logic of what you need to do.
It would be a lot easier to follow if you put your switch's 'case' statements in order, i.e. case 2 for February should come after case 1 and before case 3, but in any case, you don't need a switch to check the leap year - the month is always going to be February, month 2.
So your logic should be: if currentMonth is 2 then check for a leap year.
Your leapYear boolean needs to be declared where it can be accessed later (i.e. not inside a 'case' block), and initialised to 'false'. When you do the leap year check, assign the result to the leapYear boolean.
Last edited by dlorde; 04-07-2011 at 03:32 PM.
- 04-08-2011, 12:24 AM #22
- By rajpalparyani in forum New To JavaReplies: 3Last Post: 02-14-2011, 05:13 AM
- By SwissR in forum New To JavaReplies: 4Last Post: 07-30-2010, 01:25 PM
- By popey in forum New To JavaReplies: 2Last Post: 10-22-2009, 06:32 PM
- By Java Tip in forum java.ioReplies: 0Last Post: 04-04-2008, 03:40 PM
- By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 10:33 PM