disp('Calculates the day of year given the current date');
month = input('Enter month 1-12: ');
day   = input('Enter day 1-31: ');
year  = input('Enter year yyyy: ');

if mod(year,400) == 0
   leap_day = 1;
elseif mod(year,100) == 0
   leap_day = 0;
elseif mod(year,4) == 0
   leap_day = 1;
else
   leap_day = 0;
end

days = [day 31 28+leap_day 31 30 31 30 31 31 30 31 30 31];
day_of_year = sum(days(1:month));

fprintf('The date %2d/%2d/%4d is day of year %d.\n', ...
         month, day, year, day_of_year);

