Created
March 19, 2023 19:32
-
-
Save halilozel1903/8ec32877a3f11c049a477b9af5344695 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun isLeapYear(year: Int?): Boolean { | |
return if (year != null) { | |
(year % 4 == 0) && (year % 100 != 0 || year % 400 == 0) | |
} else { | |
false | |
} | |
} | |
fun main() { | |
print("Enter favorite year: ") | |
val year = readlnOrNull()?.toInt() | |
if (isLeapYear(year)) { | |
println("$year is a leap year.") | |
} else { | |
println("$year is not a leap year.") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment