Should be formatted to run in Matlab. CSCI 251 Section 3 Lab Assignment 3 Chines
ID: 3754279 • Letter: S
Question
Should be formatted to run in Matlab.
CSCI 251 Section 3 Lab Assignment 3 Chinesc Zadiac Problem Statement modulug o e ye cen derarmine which arimal ccrnsnds to the yer srg the ririal urikey animal gel dra For X2rmple the res' .90C s lhe res' ef lhe Rat since : 1900 rigt 12} s 4. The Chinese New se9r ie onelime in Fetruay. So ing e bove example, i the cale was Janua 1900, the eoud be he Pia, snml oferevius veer. I the cale, hoever wge Februery through are recured lo use eie elatements to gel crecit You may also eif sleteent if needed. Input Output tne menth name, the yea ard the Enimal name " Hints to use this farction Sample Output Auust 2015 is theyeate Sheep leue. 2015 is Ite Year uFthe Huse. Test CaS05 02:2020 Program ComplexityExplanation / Answer
Months = {"January","February","March","April","May","June","July","August","September","October","November","December"};
user_input = input("Enter the month and year [mm/yyyy]:",'s');
user_input = double(user_input);
month=(user_input(1)-48)*10+user_input(2)-48;
year=(user_input(4)-48)*1000+(user_input(5)-48)*100+(user_input(6)-48)*10+user_input(7)-48;
remainder = mod(year,12);
if month ==1
remainder=remainder-1
end
if remainder == -1
remainder=11
end
switch(remainder)
case 0
fprintf('%s %d is the year of Monkey ',Months{month},year);
case 1
fprintf('%s %d is the year of Hamster ',Months{month},year);
case 2
fprintf('%s %d is the year of Dog ',Months{month},year);
case 3
fprintf('%s %d is the year of Pig ',Months{month},year);
case 4
fprintf('%s %d is the year of Rat ',Months{month},year);
case 5
fprintf('%s %d is the year of Ox ',Months{month},year);
case 6
fprintf('%s %d is the year of Tiger ',Months{month},year);
case 7
fprintf('%s %d is the year of Rabbit ',Months{month},year);
case 8
fprintf('%s %d is the year of Dragon ',Months{month},year);
case 9
fprintf('%s %d is the year of Snake ',Months{month},year);
case 10
fprintf('%s %d is the year of Horse ',Months{month},year);
otherwise
fprintf('%s %d is the year of Sheep ',Months{month},year);
end