Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program that accepts a month and a year (both in numbers) from the user and prints out the number of days in that
Write a program that accepts a month and a year (both in numbers) from the user and prints out the number of days in that month. Background: There are 31 days in January, March, May, July, August, October, or December, and 30 days in April, June, September, or November. If the year is a leap year, February has 29 days, otherwise it has 28 days. Any year that is evenly divisible by 4 is a leap year. For example, 1988, 1992, and 1996 are leap years. However, there is still a small error that must be accounted for. To eliminate this error, a year that is evenly divisible by 100 (for example, 1900) is a leap year only if it is also evenly divisible by 400. For this reason, the following years are not leap years: 1700, 1800, 1900, 2100, 2200, 2300, 2500, 2600. This is because they are evenly divisible by 100 but not by 400. The following years are leap years: 1600, 2000, 2400. To determine if a number x is evenly divisible by another number y, in MATLAB, you can call a build-in function mod(x, y). If mod(x, y) is equal to 0, x is evenly divisible by y. For example, mod(1900, 100) is 0 and mod(1900, 400) is 300
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started