I would like to question the validity of this statement made about Assgn 1.3. "The tricky thing here is that a leap year occurs: on every year that is evenly divisible by 4 except every year that is evenly divisible by 100 except every year that is evenly divisible by 400. " Wouldn't that mean that the year 2000 wasn't a leap year? 2000/4 = 500 2000/100 = 20 2000/400 = 5 Please set me straight if I am misinterpreting this pseudo code.
Hello Ryan It's all in the reading... divisible by 4 = leap year! except divisible by 100 = not a leap year except divisible by 400 = leap Year! If you consider the two "excepts" as a double negative (i.e. if it's divisable by 100 but NOT divisible by 400) all within the "divisible by 4" group, being divisible by 400 would then be a leap year. This still may be a bit confusing, but I can't think of a better way to say this.... Pat B.
If only there were an easy way to do grouping with parentheses in natural language... x = year is divisible by 4 y = year is divisible by 100 z = year is divisible by 400 Year is a leap year = ( x && !y | | ( x && ( y && z ) ) ) A better way to term the requirement in natural language is : "A year is a leap year if it divisible by 4. If a year that is divisible by 4 is also divisible by 100, it is not a leap year. However, if a year is divisible by 4, 100, and 400, then it it a leap year." By this assertion 2000 was a leap year... HTH, -Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
The second except relates to the first, ie, if a year that is evenly divisible by 4 and is evenly divisible by 100 is also evenly divisible by 400 then it is a leap year. So 2000 was a leap year but 1900 was not since 1900 is evenly divisible by 4 & 100 but not by 400. John
The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai