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.
Offline
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.
Offline
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! It's much more complicated than I previously thought. I had to research this for school
Offline
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!It's much more complicated than I previously thought. I had to research this for school
![]()
Offline