This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-09-12 01:15:28

gralbrec
New Scratcher
Registered: 2011-09-12
Posts: 1

Leap Year Algorithm

Hi, I need to make a leap year algorithm for one of my classes but I'm having a difficult time doing so... can someone help me? like, put up pictures of the algorithm in scratch or talk me through it? Because I have no idea what I'm doing.  sad

Offline

 

#2 2011-09-12 02:04:31

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Leap Year Algorithm

Well, you could the fact that 1 year is actually 365.25 days long....are you trying to do a days till this date thing?  That'd be hard...but might be possible if compile a list of data such as how many days of each month in one list and the corresponding name in another, along with a designated year to be the standard for the calculator...

if you're just trying to tell the user if a year is a leap year or not, that's a lot simpler:
when flag clicked
forever
  ask "Year?" and wait
  if (2000-answer) mod (4) = 0
    say "You typed a leap year!"
  else
    say "You didn't type a leap year."
end

Basically, since the year 2000 was a leap year, if 2000-(the desired year) is evenly divisible by 4, it's a leap year.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#3 2011-09-12 02:04:56

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: Leap Year Algorithm

An explanation of the Gregorian calendar and leap years.

According to this website, a solar year is actually not 365.25 days but a little less than that, so every 100 years, the leap year is NOT a leap year. That last statement defines the difference between the Gregorian calendar which we use and the Julian calendar which didn't not have a leap year every century.

Even with all these complicated changes to the calendar, it is still very slightly off by a few seconds, so we don't not have a leap year (i.e. we have a leap year) every 4000 years. This makes it almost exact.

Here is the link to the website. It explains it quite well I think.

http://www.straightdope.com/columns/rea … leap-years

I hope that helps!  smile  It's much more complicated than I previously thought. I had to research this for school  big_smile


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#4 2011-09-13 09:13:40

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: Leap Year Algorithm

jji7skyline wrote:

An explanation of the Gregorian calendar and leap years.

According to this website, a solar year is actually not 365.25 days but a little less than that, so every 100 years, the leap year is NOT a leap year. That last statement defines the difference between the Gregorian calendar which we use and the Julian calendar which didn't not have a leap year every century.

Even with all these complicated changes to the calendar, it is still very slightly off by a few seconds, so we don't not have a leap year (i.e. we have a leap year) every 400 years. This makes it almost exact.

Here is the link to the website. It explains it quite well I think.

http://www.straightdope.com/columns/rea … leap-years

I hope that helps!  smile  It's much more complicated than I previously thought. I had to research this for school  big_smile

Offline

 

Board footer