Write a function that will receive a name and department as separate strings and will create and return a code consisting of the first two letters of the name and the last two letters of the department
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:7| Question number:8.7
All Answers
total answers (1)
nameDept.m
function outcode = nameDept(name, department)
% Creates a code from a name and department
% consisting of first two letters of the name
% and the last two of the department, upper case
% Format of call: nameDept(name, department)
% Returns the 4-character code
outcode = name(1:2);
outcode = upper(strcat(outcode, department(end-1:end)));
end
need an explanation for this answer? contact us directly to get an explanation for this answer