Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Cattle Drive and the fly likes Leap Year Logic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Leap Year Logic" Watch "Leap Year Logic" New topic

Leap Year Logic

Tom Purl
Ranch Hand

Joined: May 24, 2002
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?

Tom Purl<br />SCJP 1.4
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
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...

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Pauline McNamara

Joined: Jan 19, 2001
Posts: 4012
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
Ranch Hand

Joined: Mar 25, 2001
Posts: 1793
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

Joined: May 30, 2002
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

Joined: May 24, 2002
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

Joined: Jan 30, 2000
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.

"I'm not back." - Bill Harding, Twister
I agree. Here's the link:
subject: Leap Year Logic
It's not a secret anymore!