HW026
Math 2984 - Fall 2017
Intro to Mathematical Problem Solving


TASK: Given a calendar date like July 13, determine how many days have passed since the beginning of the year.


COMMENT: Suppose we index each day of the (nonleap) year, so that January 1 has index 1 and December 31 has index 365. Now suppose I tell you the month and day, which might be July 13. What is the corresponding index?

It will be easier for us if the user specifies the month as a number, rather than a name. So we will assume that, if the date is July 13, the user will first enter a 7 for the month, and then a 13 for the day.

The length of each month can be stored in a vector, maybe called 'days':

        31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
      


INSTRUCTIONS:

        Use MATLAB's input() statement to request values for m,
        the month number, and d, the day number.

        We are going to compute n, the number of days from the beginning
        of the year, up to this date.

        The value of n is the sum of two parts.

        Part1 is the sum of the lengths of all the months up to, but not 
        including, month m.  This can be computed with a FOR loop.

        Part2 is the day number of the current month.
 
        n = part1 + part2

        fprintf ( 'Date %d/%d has year-day index %d\n', m, d, n );
      


CHECK: Make sure 1/1 returns 1, 12/31 returns 365. Then see that the 10th day of April is day 100 of the year.


SUBMIT: Your work should be stored in a script file called "hw026.m". Your script file should begin with at least three comment lines:

        % hw026.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.