This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.

I'm doing the Java-3 (Leap) assignment, and the algorithm to sort out when a year is a leap year, or not, is doing my head in. OK, breaking it down............ A year is a leap year when:- It is evenly divisible by 4 - OK no problem Except every year that is evenly divisible by 100.

Are we therefore saying that the year 1900 is NOT a leap year because 1900/100 = 19. And the number 19 is not evenly divisible? As 1900/400 = 4.75 - NOT an even number, so the failing criteria is the '100 rule'? Except every year that is evenly divisible by 400.

Does this mean that if a year is divided by 400, for example, 2000/400 = 5, as the answer is NOT an even number, that this meets the criterion of what does constitute a leap year? 1600 is a leap year, and so is 2000. Yet they do not meet the same criterion, i.e., the both meet the '100' rule, but not the '400' rule. I am confused, big time. I am testing my leap years using this little applet:- http://www.cs.trincoll.edu/cpsc115/labs/ch5.leapyear/

John Bonham was stronger, but Keith Moon was faster.

Hi Steve, "evenly divisible" means "is divisible by"; that is, not leaving a remainder. For example 21 is evenly divisible by 7. 20 is not because dividing 20 by 7 leaves a remainder of 6. That's the direction you have to head in. Have FUN as they say... -Barry

Except every year that is evenly divisible by 100.

We are therefore saying that the year 1900 is NOT a leap year because 1900/100 = 19 with no remainder or fractional part, so the failing criteria is the '100 rule'?

Except every year that is evenly divisible by 400.

This means that if a year is divided by 400, for example, 2000/400 = 5 with no remainder or fractional part, that this meets the criterion of what does constitute a leap year?

For example 2001/400 = 5 remainder 1. Therefore it does not satisfy the "400 rule".

1600 is evenly divisible by 400 with no remainder and is a leap year, and so is 2000.

JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt

Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046

10

posted

0

Do you still have questions about this, Steve?

subject: Operators......Using them in the Leap Year Assignment