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

Floor directory The table below provides the location of an employee\'s office b

ID: 1867310 • Letter: F

Question

Floor directory The table below provides the location of an employee's office based on the employee's last name Name Floor number Hooper Lovelace McNulty Snyder Write a function called FindFloor that looks up the corresponding floor based on the user specified lastName If lastName is not recognized, then assign floorNumber with -1. The comparions with lastName should be case-insensistive, and should be independent if the data type is a string scalar or a character vector Restrictions:The function FindFloor must use a switch statement Ex >floorNumber - FindFloor('SNYDER') floorNumber - Your Function Save C Reset E MATLAB Documentation 1 function floorNumber-FindFloor(lastName) floorNumber-0; if (strcmpi(lastName, 'Hooper')) elseif (strcmpi (lastName, 'Lovelace')) elseif (strcmpi (lastName, 'McNulty)) elseif (strcmpi (lastName, 'Snyder')) else end floorNumber- 2 floorNumber-1 floorNumber- 3 floorNumber- 2 floorNumber- -1 4 4 end Feedback?

Explanation / Answer

function floorNumber = findFloor(lastName)

switch lower(lastName)
  
case 'hooper'
floorNumber =2;
case 'lovelace'
floorNumber =1;
case 'mcnulty'
floorNumber =3;
case 'snyder'
floorNumber =2;
otherwise
floorNumber =-1;
end
end