programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Tim Cooke
• Campbell Ritchie
• Ron McLeod
• Junilu Lacar
• Liutauras Vilda
Sheriffs:
• Paul Clapham
• Jeanne Boyarsky
• Henry Wong
Saloon Keepers:
• Tim Moores
• Tim Holloway
• Stephan van Hulst
• Piet Souris
• Carey Brown
Bartenders:
• Jesse Duncan
• Frits Walraven
• Mikalai Zaikin

# Java-3 Leap Question

Greenhorn
Posts: 2
• Number of slices to send:
Optional 'thank-you' note:
Hello all,
I'm a little confused by the criteria given for what determines a leap year. It says:
- every year evenly divisible by 4
- except a year that is evenly divisible by 100
- except a year that is evenly divisible by 400
Yet the example given is that the year "2000" should result in "leap year" output? Isn't 2000 evenly divisible by 100, and such, result in "not a leap year"? Also, if a year is divisible by 100, what additional criteria does "evenly divisible by 400" add? I can't think of something that is divisible by 400 that wouldn't also be divisible by 100.
Thanks!
Bob

Ranch Hand
Posts: 276
• Number of slices to send:
Optional 'thank-you' note:
2000 is divisable by 400, so it is leap
1900 is divisable by 100 but not 400, so its not a leap
1972 is divisable by 4 but not 400 or 100, so it is a leap
Good Luck
Dan
[This message has been edited by Daniel Dunleavy (edited November 05, 2001).]

tumbleweed
Posts: 5089
• Number of slices to send:
Optional 'thank-you' note:
Bob this question has been asked a few times. Try doing a search on leap in this forum.
Sorry not much time right now. Good luck

Sheriff
Posts: 9109
12
• Number of slices to send:
Optional 'thank-you' note:
You probably saw the leap() method in the section on self documenting code in the Style Guide, right? That might help clarify the algorithm.

Bob McMahon
Greenhorn
Posts: 2
• Number of slices to send:
Optional 'thank-you' note:
Oh, I get it now. If it is divisible by 400, it is a leap year so disregard the divisible by 100 criteria. Thanks

Sheriff
Posts: 4012
6
• Number of slices to send:
Optional 'thank-you' note:
As Johannes said, this question gets asked a lot. I remember having to look through search results to figure out just what the logic is (because the wording wasn't clear to me).
Is figuring out what's required actually part of the assignment?
Pauline

Marilyn de Queiroz
Sheriff
Posts: 9109
12
• Number of slices to send:
Optional 'thank-you' note:
No. It's just kinda hard to describe it succintly.

 Time flies like an arrow. Fruit flies like a banana. Steve flies like a tiny ad: Free, earth friendly heat - from the CodeRanch trailboss https://www.kickstarter.com/projects/paulwheaton/free-heat