Discuss Scratch
- Discussion Forums
- » Show and Tell
- » Leap Year Detector!! [NEW]
- LionsStair
- Scratcher
100+ posts
Leap Year Detector!! [NEW]
So I was messing around and came across the idea of a Leap Year Detector. I made it in my test project and (thanks to wiki!) I fixed it. Now I would like to go over something, people usually think this about some Leap Years:
Leap Years are these: 1900, 1700 - FALSE, why? Well to clarify a Leap Year is a year that is divisible by 4 and 400, or is NOT divisible by 100, yes I know it may sound confusing but it makes sense for 1900 not to be a Leap Year while 1904 IS and so is 2000, but remember what I said, 1700 CANNOT be a Leap Year.
But anyways here is the Scratch version of what I said above(NOT THE DETECTOR):
So anyways I use that method to make my detector which is here (You need both blocks because the “LeapYear? (year)” needs the other):
I will try to fix all buggy scratch blocks as soon as possible!
Please don't be rude about my mistakes! Every human makes mistakes, it's what makes us, well, HUMAN.
If you see ANY mistakes please tell me immediately!
Thanks for spending your time here!
Leap Years are these: 1900, 1700 - FALSE, why? Well to clarify a Leap Year is a year that is divisible by 4 and 400, or is NOT divisible by 100, yes I know it may sound confusing but it makes sense for 1900 not to be a Leap Year while 1904 IS and so is 2000, but remember what I said, 1700 CANNOT be a Leap Year.
But anyways here is the Scratch version of what I said above(NOT THE DETECTOR):
<((year) mod (4)) = [0 ]> and < <<not <((year) mod (100)) = [0 ]>> or <<((year) mod (400)) = [0 ]> >>>If there are any issues tell me!
So anyways I use that method to make my detector which is here (You need both blocks because the “LeapYear? (year)” needs the other):
define LeapYear? (number1)//Specified Year
if <<((number1) mod (4)) = [0 ]> and < <<not <((number1) mod (100)) = [0 ]>> or <<((number1) mod (400)) = [0 ]> >>>> then
say [It is a Leap Year!!]
else
say [It is NOT a Leap Year!!] for (2) secs
say (join [It will be in ] (join (DisTillLeapYear?) [ years]))
end
define WhenLeapYear? (number1)//Year specified, output is "DisTillLeapYear?"
set [DisTillLeapYear? v] to [0 ]//If the repeat until instantly returns true then it will output 0 automatically
set [yeartemp v] to [(number1) ]
repeat until <<((yeartemp) mod (4)) = [0 ]> and <<<not <((yeartemp) mod (100)) = [0 ]>> or <<((yeartemp) mod (400)) = [0 ]> >> >>
set [yeartemp v] to [((yeartemp) + (1)) ]
change [DisTillLeapYear? v] by (1)
end
I will try to fix all buggy scratch blocks as soon as possible!
Please don't be rude about my mistakes! Every human makes mistakes, it's what makes us, well, HUMAN.
If you see ANY mistakes please tell me immediately!
Thanks for spending your time here!
- Discussion Forums
- » Show and Tell
- » Leap Year Detector!! [NEW]