File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Leap Year Code" Watch "Leap Year Code" New topic
Author

Leap Year Code

Maritza Keisman
Greenhorn

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
Marshal

Joined: Mar 22, 2005
Posts: 42946
    
  70
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
Greenhorn

Joined: Mar 28, 2006
Posts: 7
Thanks, that helped resolve the issue. Found a leap year calculator so that you can check results, see:

http://www.onlineconversion.com/leapyear.htm
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Leap Year Code