Posted by: lootekukur September 29, 2006
Java Help
Login in to Rate this Post:     0       ?        
Slack, i don't understand, why you are having a tough time with the logic. it's pretty straightforward. anyways, you can either use the nested loop (that i coded) or one or two if statements. it's all up to you. I think you are incorrect in #1. Something that is divisible by 4 IS leap year UNLESS it is also divisible by 100! that is exactly what i said ONLY if you had read my last post clearly. see what i wrote: 1) is not sufficient....if a year is divisible by 4, it should NOT be divisible by 100 or if it is divisible by 100 then it should be by 400 AS WELL.. NOW that you have understood the logic, WHY your code still not right? if (y % 4 ==0 && y % 100 != 0 || y%100 == 0 && y % 400 == 0) return true; else return false; Either use the nested loop logic that i coded in my last post or use this: if(year%4==0&&year%!=100)|| if(year%4==0&&year%100==0&&year%400==0) return 1; else return 0;
Read Full Discussion Thread for this article