my dog learned polymorphism
The moose likes Cattle Drive and the fly likes Java 3 Leap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Java 3 Leap" Watch "Java 3 Leap" New topic

Java 3 Leap

Bob Beasley

Joined: Nov 06, 2002
Posts: 5
I don't understand this one. Year 2000 is / 4 but your next 2 rules would exclude it from being a leap year?
Write a program that will read in a year and report if it is a leap year. 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.
In other words, I want to type
java Leap 2000

and see
leap year!
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9059
If you search (at the top of the page under the Post New Topic/Post Reply buttons) for "leap year" in this forum, you'll find quite a few threads like this one regarding this very same question.

This question does not have a succinct one-statement-fits-everyone's-understanding type answer. You're probably better off reading the multiple replies you'll find in the search. However, if it still doesn't make sense, we'll try again to explain it, because you can't very well do the assignment without understanding the algorithm.

By the way, welcome to the Cattle Drive
[ November 06, 2002: Message edited by: Marilyn de Queiroz ]

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

Joined: Aug 03, 2002
Posts: 7729
From "High-Tech Dictionary":
Leap years fall on any year that either can be evenly divided by 400 or evenly divided by 4 and not evenly divided by 100.For example, the year 2000 is a leap year, but 1900 is not.

From "Cisco Year 2000 Compliance Definition:"
Leap Year occurs in all years divisible by 400 or evenly divisible by 4 and not evenly divisible by 100. For example, 1996 is a Leap Year since it is divisible by 4 and not evenly divisible by 100. The year 2000 is a Leap Year since it is divisible by 400.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
I agree. Here's the link:
subject: Java 3 Leap
It's not a secret anymore!