Strings Write a function that will receive a name and department as separate str
ID: 2080060 • Letter: S
Question
Strings Write a function that will receive a name and department as separate strings and will create and return a code consisting of the last two letters of the name and the first two letters of the department. The code should be in uppercase. For example, >>create Code('David', 'Engineering') ans = IDEN Calendar (Strings) Write a MATLAB program that will prompt the user to enter the current month as a string (like "september" or Septembe r") then display the number of days in the month that they specified. Note that September, April, June, and November have 30 days, February has 28 or 29 days, and all the other months have 31 days. If the user does not enter a valid month name, display an appropriate error message. The program should continue running until the user input the string "Exit" or "exit".Explanation / Answer
Problem 4:
function [word]=createCode(word1,word2)
n1=length(word1);
n2=length(word2);
word(1:2)=word1(n1-1:n1);
word(3:4)=word2(1:2);
word=upper(word);
end
OUTPUT:
>> createCode('David','Engineering')
ans =
IDEN
Problem 5:
clc; clear all; close all;
month=input('Enter Current month (like January or january) : ','s');
mon={'January','February','March','April','May','June','July','August','September','October','November','December'};
days=[31 28 31 30 31 30 31 31 30 31 30 31];
j=0;
while ~(strcmpi(month,'exit'));
for i=1:1:12
if(strcmpi(month,mon(i)))
X=sprintf('The number of days in %s is %d days',month,days(i));
disp(X);
j=j+1;
end
end
if (j==1)
fprintf('Invalid Input');
end
month=input('Enter Current month (like January or january) : ','s');
end
OUTPUT:
Enter Current month (like January or january) : may
The number of days in may is 31 days
Invalid InputEnter Current month (like January or january) : january
The number of days in january is 31 days
Enter Current month (like January or january) : exit
>>