permaculture playing cards
The moose likes Cattle Drive and the fly likes Leap Year Code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Leap Year Code" Watch "Leap Year Code" New topic

Leap Year Code

Maritza Keisman

Joined: Mar 28, 2006
Posts: 7
I fouund code on the internet which would satisfy the leap year coding requirements Assignment:

lp = ((y % 4 = 0) AND (y % 100 <> 0)) OR (y % 400 = 0)

However, I am having a lot of difficulty translating this into Java. Keep on getting a lot of syntax errors. I have tried various iterations and keep on getting compile errors.

Many thanks.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42958
Try to replace the operators one by one:

"AND" is the same as what in Java ?
"OR" is the same as ...
"=" is ...
"<>" is ...
Maritza Keisman

Joined: Mar 28, 2006
Posts: 7
Thanks, that helped resolve the issue. Found a leap year calculator so that you can check results, see:
I agree. Here's the link:
subject: Leap Year Code
It's not a secret anymore!