Post

Replies

Boosts

Views

Activity

Reply to Leap Year Exercise in Lesson 11 (Making Decisions.Playground)
 let aYear = 1700 // change year here to test the function   func isLeap (year: Int){       if (aYear % 4 == 0 && aYear % 100 == 0 && aYear % 400 == 0) || (aYear % 4 == 0 && aYear % 100 != 0){     print("YES")   } else {     print("NO")   } } isLeap(year: aYear) //function call This seemed the most straightforward way to solve it. A year is a leap year in two cases. Case 1: The year equally divided by 4 AND equally divided by 100 AND while equally divided by 400. OR Case 2: The year is equally divided by 4 AND is NOT equally divided by 100.
Jan ’21