Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!

# Leap Year Logic

Tom Purl
Ranch Hand
Posts: 104
Hey! I just wanted to formally say hi to everyone as I started the cattle drive about two weeks ago. I'm happy to say that everything that I read about this service was true. It's really been great so far and I'm learning a *ton* of great stuff.
Having said that, I would like to get the opinion of my fellow cattledrivers regarding the wording of the "Leap" assignment. I think that the explanation of a leap year is a little misleading.

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.

After reading this, I thought that a leap year was any year evenly divisible by four, except if it's evenly divisible by 100 or 400. Now, I know that every year divisible by 400 is also divisible by 100; this added to my confusion. In the end, I finally figured it out after visiting this leap year site (which is very funny if you have the time).
Before I babble any more, has anyone else encountered this problem with the wording? Is confusion about this a frequent source of errors with this assignment? Or is it just me?

Barry Gaunt
Ranch Hand
Posts: 7729
Hello Tom,
welcome to the gang! I'm sure you will have an enlightening experience working through the Cattledrive assignments.
I did the same as you for this assignment. I went off and looked at a couple more definitions before attempting to program a solution. But that's just part of the experience...
-Barry

Pauline McNamara
Sheriff
Posts: 4012
6
Hi Tom, welcome to the abuse.
There have been many confused by that wording (a search in this forum under "leap" calls up 58 threads!).
I'm not sure if part of the assignment's goal is to practice decoding specifications, or using the forum search option , but I remember having to go through older posts before I was sure I understood it. There are many posts with more wordy explanations of what makes a leap year leap.
Babble on Tom! (No drooling though, OK? )

Michael Matola
whippersnapper
Ranch Hand
Posts: 1817
4
It was clear to me, but I already knew about leap years before doing the assignment.
A leap year occurs
on every year that is evenly divisible by 4
that is not also evenly divisible by 100
unless it happens also to be evenly divisible by 400.

juliane gross
Ranch Hand
Posts: 161
I like your wording, Michael.
I also started this assignment first thing reading other leap year definitions, and also one in my mother language, to make sure that I got it right.
But since I am convinced that this is a (however subtle) part of the assignment, I vote against rewording, because Michaels proposal is just too clear and outright to understand..

Tom Purl
Ranch Hand
Posts: 104
Thanks for the comments! While completing this assignment I also used the Javaranch search feature for the first time, so maybe that is part of the assignment. I guess it should probably stay the way it is.

Jim Yingst
Wanderer
Sheriff
Posts: 18671
There are various ways to make the wording clearer or more precise, but they also tend to make the wording look more like the solution to the programming problem. I think the current wording works well as an excercise in interpreting user specifications and doing external research.