'Write a program that takes in a year and determines whether that year is a leap year in Coral
Ex: If the input is 1712, the output is:
1712 is a leap year.
Ex: If the input is 1913, the output is:
1913 is not a leap year.
integer inputYear
inputYear = Get next input
if inputYear / 4 == 0
Put inputYear to output
Put " is a leap year." to output
elseif inputYear / 400 == 0
Put inputYear to output
Put " is a leap year." to output
elseif inputYear / 100 == 0
Put inputYear to output
Put " is a leap year." to output
else
Put inputYear to output
Put " is not a leap year." to output
I'm not wanting the answer, just help with my code. I can't figure out why the if/elseif statements aren't executing.
Solution 1:[1]
I can't figure out why the if/elseif statements aren't executing.
It's executing, but take 1712 as an example, 1712/4 != 0, and therefore never passes the condition for the if statement. Matter fact, it doesn't pass any of those above conditions.
What you want is modulo math: %.
FYI, check your algorithm.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
