Question

Write a Swift program to Check whether a year between 2000 and 2500 is a leap...

Write a Swift program to
Check whether a year between 2000 and 2500 is a leap year, and output results.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

var index = 2000
/*Iterating from 2000 to 2500*/

while index < 2500 {
/*Checking if year is leap year*/
let isLeapYear = ((index % 4 == 0) && (index % 100 != 0) || (index % 400 == 0))
/*If yes than print the year*/
if isLeapYear {
print(index)
}
index = index + 1
}

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
Write a Swift program to Check whether a year between 2000 and 2500 is a leap...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that accepts a year and determines whether the year is a leap year....

    Write a program that accepts a year and determines whether the year is a leap year. Use the mod function. The output should be the variable extra_day, which should be 1 if the year is a leap year and 0 otherwise. The rules for determining leap years in the Gregorian calendar are as follows: All years evenly divisible by 400 are leap years. Years evenly divisible by 100 but not by 400 are not leap years. Years divisible by 4...

  • 4) Write a shell script to find whether a year was leap year or not. The...

    4) Write a shell script to find whether a year was leap year or not. The script will take input from user. The user will enter a year (will only input a valid year) e.g. 1957. The output will be it's a leap year" if it is and "It's not a leap year" if it is not

  • PLEASE WRITE CODE FOR C++ ! Time Validation, Leap Year and Money Growth PartA: Validate Day and Time Write a program tha...

    PLEASE WRITE CODE FOR C++ ! Time Validation, Leap Year and Money Growth PartA: Validate Day and Time Write a program that reads a values for hour and minute from the input test file timeData.txt . The data read for valid hour and valid minute entries. Assume you are working with a 24 hour time format. Your program should use functions called validateHour and validateMinutes. Below is a sample of the format to use for your output file  timeValidation.txt :   ...

  • Python Programming Task 2: Leap Years   Part A - Is this a leap year? Write a...

    Python Programming Task 2: Leap Years   Part A - Is this a leap year? Write a function is leap year(year) that calculates whether a given (CE) year is a leap year. The function must: • take one argument: a positive integer representing a year (assumed to be CE) • return True if that year was a leap year; return False if not NOTE: all years that are divisible by four are leap years, unless they are also divisible by 100,...

  • leap year C++

    the instructions are: A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are:1) The year must be divisible by 42) If the year is a century year...

  • FINDING THE LEAP YEARS (14 points) From Wikipedia, "A leap year (also known as an intercalary...

    FINDING THE LEAP YEARS (14 points) From Wikipedia, "A leap year (also known as an intercalary year or bissextile year) is a calendar year containing one additional day (or, in the case of lunisolar calendars, a month) added to keep the calendar year synchronized with the astronomical or seasonal year." In the Gregorian calendar, which is in use today, to determine leap year: A year is a leap year if it is divisible by 400 Or it is divisible by...

  • In Python 3 please 3.28 LAB: Leap year A year in the modern Gregorian Calendar consists...

    In Python 3 please 3.28 LAB: Leap year A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are: 1) The year must be divisible by 4...

  • Has to be written in C++ Write a program that asks the user to enter the...

    Has to be written in C++ Write a program that asks the user to enter the month (1-12) and the year (0-2019). Validate the input and print an error and stop the program if an invalid month or year was entered. The program should then display the number of days in that month. Use the following criteria to identify leap years: Determine whether the year is divisible by 100. If it is, then it is a leap year if and...

  • 3. Using no date-specific Java libraries, write a program that computes the number of days between...

    3. Using no date-specific Java libraries, write a program that computes the number of days between any two dates (inclusive). You must take into account leap years. The rule for computing a leap year is as follows: If the year is divisible by 4 it is a Leap Year ... Unless the year is divisible by 100, then it is _not_ a Leap Year ... Unless the year is divisible by 400, then it _is_ a Leap Year. During a...

  • Use the program MATLAB to answer the following question:Use the program MATLAB to answer the following...

    Use the program MATLAB to answer the following question:Use the program MATLAB to answer the following question: KE Mona File Use The Program MATLA x 0 Info Assignment 8, Matlab, spring 2017.docx O Download Close box 2/2 5. Write a program that accepts a year and determines whether the year is a leap year. Use the mod function. The output should be the variable extra day, which should be 1 if the year is a leap year and 0 otherwise....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT