Question: The MATLAB question A. Write a function that accepts a year as input and determines whether it is a leap year. The function should return

The MATLAB question

The MATLAB question A. Write a function that accepts a year as

A. Write a function that accepts a year as input and determines whether it is a leap year. The function should return 1 if the year is a leap year, otherwise return 0. The rules for determining leap years are as follows: 1. All years evenly divisible by 400 are leap years 2. Years evenly divisible by 100 but not by 400 are NOT leap years 3. Years divisible by 4 but not 100 are leap years All other years are NOT leap years 4. For example, 1800, 1900, 2100 are not leap years. 2000, 2004 and 2400 are leap years. Hint: You may want to use the mod() function and if statements write an m-file that asks the user for the month (1 to 12) and the year then prints the number of days in the month, taking leap years into account by reusing the function you wrote for part A. For example, if the user enters 2 (February) and 2004 (leap year), the program should print the following B. Please enter month (1 to 12): 2 Please enter year: 2004 2004-02 has 29 days Hint: You may want to try switch statements

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!