TASK: Determine what month the N-th day occurs in, using a vector.
COMMENT: The first day of the year is in January. The 365-th day of the year is in December. When does day 100 occur? If you think about it, you might guess April, but now you need to write a program to answer this question.
You should use a vector that stores the length of each month. For a non-leap-year like 2017, these lengths are:
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31Be sure you understand how to create a single variable, a vector, that stores all these values under one name.
INSTRUCTIONS:
Use MATLAB's input() statement to request a value for n, the day number, between 1 and 365. Use a for loop, with counter "m" running from 1 to 12. Inside of that loop, you need to determine if day n occurs in month m. You can do this by comparing n to "t", the total number of days that have passed by the end of this month. Before the loop, set t to 0. Each time you do the loop, add this month's length to t. t = t + ?; <--- How do you add this month's length? Thus, the first time in the loop, you will ask whether n is less than or equal to t = 31. IF this condition is true, print a message that "day n is in month m" BREAK out of the loop end of your IF check end of your FOR loop
SUBMIT: Your work should be stored in a script file called "hw017.m". Your script file should begin with at least three comment lines:
% hw017.m % YOUR NAME % This script (describe what it does) % Add any comments here that you care to make.If this problem is part of an assignment, then submit it to Canvas.