I need helpwriting the script for the following assignment. Write a program that
ID: 3542081 • Letter: I
Question
I need helpwriting the script for the following assignment.
Write a program that inputs a date and outputs the day of the week for that date. Your program should work as follows: Enter the year (1801 middot middot 2199) > 2007 Enter the month number (January = 1) > 1 Enter the day (1 middotmiddot 31) > 25 Thursday The program should work for dates from January 1, 1801 to December 31, 2199. You do not have to reject values like February 31. 2007 which are potentially legal values but do not represent actual dates. Perform the following algorithm. Assume Year. Month, and Day are the input values with January = 1, February = 2, etc. After doing all that, the variable D will contain the day of the week, encoded with Sunday = 1, Monday = 2, etc. Many algorithms use integer division, and this is no exception. It is possible to set variables with an integer data type, but unlike most other programming languages, MATLAB/Octave/Scilab will perform floating point division, and round the result to the nearest integer. Using the floor function, we can simulate the behaviour of standard integer division. C = floor(Year/100); L = floor(Year/4) - floor((3*C + 3)/4); CI = (Year - 1/100; Leap = L - floor((Year - l)/4) + floor((3*Cl + 3)/4); Adj = 1 - floor((Month + 9)/12); M = floor((13*Month + 3 + 17*Adj)/5); M = M - (Leap + l)*Adj; D = mod((Year + L + M + Day + 1), 7) +1; Use a cell array to output the text matching the correct day. Create a cell array with one entry for each day of the week, and display item D from that cell array. Pick a few wrell chosen values and test your program. Try dates around the first of the year and the end of February, and dates which are easy to verify are correct (today for example).Explanation / Answer
Year = input('Enter the year (1801 .. 2199) ');
Month = input('Enter the month number (January = 1) ');
Day = input('Enter the day (1 .. 31) ');
week = cellstr(["Sunday";"Monday";"Tuesday";"Wednesday";"Thursday";"Friday";"Saturday"]);
C = floor(Year/100);
L = floor(Year/4) - floor((3*C +3)/4);
C1 = (Year -1)/100;
Leap = L - floor((Year -1)/4) + floor((3*C1 + 3)/4);
Adj = 1 - floor((Month + 9)/12);
M = floor((13*Month + 3 + 17*Adj)/5);
M = M - (Leap +1)*Adj;
D = pmodulo((Year + L + M + Day + 1),7) +1;
disp(week(D).entries);