Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Java 3 Leap

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand this one. Year 2000 is / 4 but your next 2 rules would exclude it from being a leap year?
Thanks
Bob
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!
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

 
I will open the floodgates of his own worst nightmare! All in a tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic