Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MATLAB Help: Cell Arrays Thank you for the help! :) 2. (30 pts) Write a program

ID: 3699567 • Letter: M

Question


MATLAB Help: Cell Arrays

Thank you for the help! :)

2. (30 pts) Write a program that prompts for the month and the year, and then display how many days in that month. The input for the month should be an integer between 1 and 12; the input for the year must be positive integer. Your program will trap the user for bad input. Do count for leap years. You have already created a function, daysinmonthO, that will return how many days in a month in a year. Feel free to call the function. Months should be represented by their names, not a numeric value. Instead of using an IF statement, you should create a cell array that stores all 12 month names, and reference it. Enter the month: 13 Try again. Enter a whole number between 1 and 12: 3 Enter the year (YYYY): 2016 There are 31 days in March, 2016.

Explanation / Answer

Solution:

code:

monthValue=input('Enter a monthValue of 2016: ');
m_string={'January','February','March','April','May','June','July','Aug','September','October','November','December'};
while 1
if (monthValue<0) || (monthValue >=12)
fprintf('Try again. ');
monthValue=input('Enter a whole number between 1 to 12: ');
else
fprintf('They are %d in %s , 2016 ', eomday(2016, monthValue) , m_string(monthValue));
break;
end
end?

I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)