This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Leap Year Code

 
Maritza Keisman
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, that helped resolve the issue. Found a leap year calculator so that you can check results, see:

http://www.onlineconversion.com/leapyear.htm
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic