This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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 Java 8 in Action this week in the Java 8 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: 39578
Try to replace the operators one by one:

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

Ping & DNS - updated with new look and Ping home screen widget
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:
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Leap Year Code
Similar Threads
please verify this code
unreachable statement error
Leap year program
two puzzling errors
Leap Year program